| 74 | } |
| 75 | |
| 76 | bool SingleEndProcessor::process(){ |
| 77 | if(!mOptions->split.enabled) |
| 78 | initOutput(); |
| 79 | |
| 80 | mInputLists = new SingleProducerSingleConsumerList<ReadPack*>*[mOptions->thread]; |
| 81 | |
| 82 | ThreadConfig** configs = new ThreadConfig*[mOptions->thread]; |
| 83 | for(int t=0; t<mOptions->thread; t++){ |
| 84 | mInputLists[t] = new SingleProducerSingleConsumerList<ReadPack*>(); |
| 85 | configs[t] = new ThreadConfig(mOptions, t, false); |
| 86 | configs[t]->setInputList(mInputLists[t]); |
| 87 | initConfig(configs[t]); |
| 88 | } |
| 89 | |
| 90 | std::thread readerThread(std::bind(&SingleEndProcessor::readerTask, this)); |
| 91 | |
| 92 | std::thread** threads = new thread*[mOptions->thread]; |
| 93 | for(int t=0; t<mOptions->thread; t++){ |
| 94 | threads[t] = new std::thread(std::bind(&SingleEndProcessor::processorTask, this, configs[t])); |
| 95 | } |
| 96 | |
| 97 | std::thread* leftWriterThread = NULL; |
| 98 | std::thread* failedWriterThread = NULL; |
| 99 | if(mLeftWriter) |
| 100 | leftWriterThread = new std::thread(std::bind(&SingleEndProcessor::writerTask, this, mLeftWriter)); |
| 101 | if(mFailedWriter) |
| 102 | failedWriterThread = new std::thread(std::bind(&SingleEndProcessor::writerTask, this, mFailedWriter)); |
| 103 | |
| 104 | readerThread.join(); |
| 105 | for(int t=0; t<mOptions->thread; t++){ |
| 106 | threads[t]->join(); |
| 107 | } |
| 108 | |
| 109 | if(!mOptions->split.enabled) { |
| 110 | if(leftWriterThread) |
| 111 | leftWriterThread->join(); |
| 112 | if(failedWriterThread) |
| 113 | failedWriterThread->join(); |
| 114 | } |
| 115 | |
| 116 | if(mOptions->verbose) |
| 117 | loginfo("start to generate reports\n"); |
| 118 | |
| 119 | // merge stats and read filter results |
| 120 | vector<Stats*> preStats; |
| 121 | vector<Stats*> postStats; |
| 122 | vector<FilterResult*> filterResults; |
| 123 | for(int t=0; t<mOptions->thread; t++){ |
| 124 | preStats.push_back(configs[t]->getPreStats1()); |
| 125 | postStats.push_back(configs[t]->getPostStats1()); |
| 126 | filterResults.push_back(configs[t]->getFilterResult()); |
| 127 | } |
| 128 | Stats* finalPreStats = Stats::merge(preStats); |
| 129 | Stats* finalPostStats = Stats::merge(postStats); |
| 130 | FilterResult* finalFilterResult = FilterResult::merge(filterResults); |
| 131 | |
| 132 | // read filter results to the first thread's |
| 133 | for(int t=1; t<mOptions->thread; t++){ |
no test coverage detected