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