| 56 | |
| 57 | template<typename TDatums> |
| 58 | void WQueueAssembler<TDatums>::work(std::shared_ptr<TDatums>& tDatums) |
| 59 | { |
| 60 | try |
| 61 | { |
| 62 | // Profiling speed |
| 63 | const auto profilerKey = Profiler::timerInit(__LINE__, __FUNCTION__, __FILE__); |
| 64 | // Input TDatums -> enqueue it |
| 65 | if (checkNoNullNorEmpty(tDatums)) |
| 66 | { |
| 67 | // Sanity check |
| 68 | if (tDatums->size() > 1) |
| 69 | error("This function assumes that WQueueSplitter (inside WDatumProducer)" |
| 70 | " was applied in the first place, i.e., that there is only 1 element" |
| 71 | " per TDatums (size = " + std::to_string(tDatums->size()) + ").", |
| 72 | __LINE__, __FUNCTION__, __FILE__); |
| 73 | auto tDatumPtr = (*tDatums)[0]; |
| 74 | // Single view --> Return |
| 75 | if (tDatumPtr->subIdMax == 0) |
| 76 | return; |
| 77 | // Multiple view --> Merge views into different TDatums (1st frame) |
| 78 | if (mNextTDatums == nullptr) |
| 79 | mNextTDatums = std::make_shared<TDatums>(); |
| 80 | // Multiple view --> Merge views into different TDatums |
| 81 | mNextTDatums->emplace_back(tDatumPtr); |
| 82 | // Last view - Return frame |
| 83 | if (mNextTDatums->back()->subId == mNextTDatums->back()->subIdMax) |
| 84 | { |
| 85 | tDatums = mNextTDatums; |
| 86 | mNextTDatums = nullptr; |
| 87 | // Profiling speed |
| 88 | Profiler::timerEnd(profilerKey); |
| 89 | Profiler::printAveragedTimeMsOnIterationX(profilerKey, __LINE__, __FUNCTION__, __FILE__); |
| 90 | // Debugging log |
| 91 | opLogIfDebug("", Priority::Low, __LINE__, __FUNCTION__, __FILE__); |
| 92 | } |
| 93 | // Non-last view - Return nothing |
| 94 | else |
| 95 | tDatums = nullptr; |
| 96 | } |
| 97 | // Sleep if no new tDatums to either pop or push |
| 98 | else |
| 99 | std::this_thread::sleep_for(std::chrono::milliseconds{1}); |
| 100 | } |
| 101 | catch (const std::exception& e) |
| 102 | { |
| 103 | this->stop(); |
| 104 | tDatums = nullptr; |
| 105 | error(e.what(), __LINE__, __FUNCTION__, __FILE__); |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | extern template class WQueueAssembler<BASE_DATUMS>; |
| 110 | } |
nothing calls this directly
no test coverage detected