1 #ifndef OPENPOSE_THREAD_THREAD_QUEUE_IN_OUT_HPP
2 #define OPENPOSE_THREAD_THREAD_QUEUE_IN_OUT_HPP
11 template<
typename TDatums,
typename TWorker = std::shared_ptr<Worker<TDatums>>,
typename TQueue = Queue<TDatums>>
15 SubThreadQueueInOut(
const std::vector<TWorker>& tWorkers,
const std::shared_ptr<TQueue>& tQueueIn,
16 const std::shared_ptr<TQueue>& tQueueOut);
23 std::shared_ptr<TQueue> spTQueueIn;
24 std::shared_ptr<TQueue> spTQueueOut;
37 template<
typename TDatums,
typename TWorker,
typename TQueue>
39 const std::shared_ptr<TQueue>& tQueueIn,
40 const std::shared_ptr<TQueue>& tQueueOut) :
43 spTQueueOut{tQueueOut}
46 spTQueueOut->addPusher();
49 template<
typename TDatums,
typename TWorker,
typename TQueue>
54 template<
typename TDatums,
typename TWorker,
typename TQueue>
60 if (!spTQueueOut->isRunning())
70 if (!spTQueueOut->isFull())
73 if (spTQueueIn->empty())
74 std::this_thread::sleep_for(std::chrono::microseconds{100});
76 bool workersAreRunning = spTQueueIn->tryPop(tDatums);
78 if (!workersAreRunning)
79 workersAreRunning = spTQueueIn->isRunning();
81 workersAreRunning = this->workTWorkers(tDatums, workersAreRunning);
83 if (workersAreRunning)
85 if (tDatums !=
nullptr)
86 spTQueueOut->waitAndEmplace(tDatums);
92 spTQueueOut->stopPusher();
94 return workersAreRunning;
98 std::this_thread::sleep_for(std::chrono::microseconds{100});
103 catch (
const std::exception& e)
105 error(e.what(), __LINE__, __FUNCTION__, __FILE__);
virtual ~SubThreadQueueInOut()
SubThreadQueueInOut(const std::vector< TWorker > &tWorkers, const std::shared_ptr< TQueue > &tQueueIn, const std::shared_ptr< TQueue > &tQueueOut)
COMPILE_TEMPLATE_DATUM(WPoseTriangulation)
OP_API void error(const std::string &message, const int line=-1, const std::string &function="", const std::string &file="")