| 131 | |
| 132 | |
| 133 | bool PairEndProcessor::process(){ |
| 134 | if(!mOptions->split.enabled) |
| 135 | initOutput(); |
| 136 | |
| 137 | std::thread* readerLeft = NULL; |
| 138 | std::thread* readerRight = NULL; |
| 139 | std::thread* readerInterveleaved = NULL; |
| 140 | |
| 141 | mLeftInputLists = new SingleProducerSingleConsumerList<ReadPack*>*[mOptions->thread]; |
| 142 | mRightInputLists = new SingleProducerSingleConsumerList<ReadPack*>*[mOptions->thread]; |
| 143 | |
| 144 | ThreadConfig** configs = new ThreadConfig*[mOptions->thread]; |
| 145 | for(int t=0; t<mOptions->thread; t++){ |
| 146 | mLeftInputLists[t] = new SingleProducerSingleConsumerList<ReadPack*>(); |
| 147 | mRightInputLists[t] = new SingleProducerSingleConsumerList<ReadPack*>(); |
| 148 | configs[t] = new ThreadConfig(mOptions, t, true); |
| 149 | configs[t]->setInputListPair(mLeftInputLists[t], mRightInputLists[t]); |
| 150 | initConfig(configs[t]); |
| 151 | } |
| 152 | |
| 153 | if(mOptions->interleavedInput) |
| 154 | readerInterveleaved= new std::thread(std::bind(&PairEndProcessor::interleavedReaderTask, this)); |
| 155 | else { |
| 156 | readerLeft = new std::thread(std::bind(&PairEndProcessor::readerTask, this, true)); |
| 157 | readerRight = new std::thread(std::bind(&PairEndProcessor::readerTask, this, false)); |
| 158 | } |
| 159 | |
| 160 | std::thread** threads = new thread*[mOptions->thread]; |
| 161 | for(int t=0; t<mOptions->thread; t++){ |
| 162 | threads[t] = new std::thread(std::bind(&PairEndProcessor::processorTask, this, configs[t])); |
| 163 | } |
| 164 | |
| 165 | std::thread* leftWriterThread = NULL; |
| 166 | std::thread* rightWriterThread = NULL; |
| 167 | std::thread* unpairedLeftWriterThread = NULL; |
| 168 | std::thread* unpairedRightWriterThread = NULL; |
| 169 | std::thread* mergedWriterThread = NULL; |
| 170 | std::thread* failedWriterThread = NULL; |
| 171 | std::thread* overlappedWriterThread = NULL; |
| 172 | if(mLeftWriter) |
| 173 | leftWriterThread = new std::thread(std::bind(&PairEndProcessor::writerTask, this, mLeftWriter)); |
| 174 | if(mRightWriter) |
| 175 | rightWriterThread = new std::thread(std::bind(&PairEndProcessor::writerTask, this, mRightWriter)); |
| 176 | if(mUnpairedLeftWriter) |
| 177 | unpairedLeftWriterThread = new std::thread(std::bind(&PairEndProcessor::writerTask, this, mUnpairedLeftWriter)); |
| 178 | if(mUnpairedRightWriter) |
| 179 | unpairedRightWriterThread = new std::thread(std::bind(&PairEndProcessor::writerTask, this, mUnpairedRightWriter)); |
| 180 | if(mMergedWriter) |
| 181 | mergedWriterThread = new std::thread(std::bind(&PairEndProcessor::writerTask, this, mMergedWriter)); |
| 182 | if(mFailedWriter) |
| 183 | failedWriterThread = new std::thread(std::bind(&PairEndProcessor::writerTask, this, mFailedWriter)); |
| 184 | if(mOverlappedWriter) |
| 185 | overlappedWriterThread = new std::thread(std::bind(&PairEndProcessor::writerTask, this, mOverlappedWriter)); |
| 186 | |
| 187 | if(readerInterveleaved) { |
| 188 | readerInterveleaved->join(); |
| 189 | } else { |
| 190 | readerLeft->join(); |
no test coverage detected