Changeset 4979 for icGREP/icgrep-devel


Ignore:
Timestamp:
Mar 16, 2016, 3:12:07 PM (3 years ago)
Author:
lindanl
Message:

Change GrepEngine? from a global variable to an argument to the threads.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/icgrep.cpp

    r4972 r4979  
    103103}
    104104
    105 GrepEngine grepEngine;
    106105std::mutex count_mutex;
    107 
    108106size_t fileCount;
    109 void *DoGrep(void *threadid)
     107void *DoGrep(void *args)
    110108{
    111     long tid;
    112     tid = (long)threadid;
    113109    size_t fileIdx;
     110    GrepEngine * grepEngine = (GrepEngine *)args;
    114111
    115112    count_mutex.lock();
     
    117114    fileIdx = fileCount;
    118115    count_mutex.unlock();
    119    
     116
    120117    while (fileIdx < inputFiles.size()){
    121         grepEngine.doGrep(inputFiles[fileIdx]);
     118        grepEngine->doGrep(inputFiles[fileIdx]);
    122119       
    123120        count_mutex.lock();
     
    162159    std::string module_name = "grepcode:" + sha1sum(allREs) + ":" + std::to_string(globalFlags);
    163160   
     161    GrepEngine grepEngine;
    164162    grepEngine.grepCodeGen(module_name, re_ast);
    165163
     
    174172
    175173        for(unsigned long i = 0; i < numOfThreads; ++i){
    176             const int rc = pthread_create(&threads[i], NULL, DoGrep, (void *)i);
     174            const int rc = pthread_create(&threads[i], NULL, DoGrep, (void *)&grepEngine);
    177175            if (rc) {
    178176                throw std::runtime_error("Failed to create thread: code " + std::to_string(rc));
Note: See TracChangeset for help on using the changeset viewer.