1 #ifndef FWCore_Concurrency_LimitedTaskQueue_h 2 #define FWCore_Concurrency_LimitedTaskQueue_h 52 void push(
T&& iAction);
89 iOther.m_queue =
nullptr;
112 template <
typename T>
125 template <
typename T>
127 auto set_to_run = std::make_shared<std::atomic<bool>>(
false);
129 q.push([set_to_run, iAction]()
mutable {
130 bool expected =
false;
131 if (set_to_run->compare_exchange_strong(expected,
true)) {
138 template <
typename T>
140 tbb::empty_task* waitTask =
new (tbb::task::allocate_root()) tbb::empty_task;
141 waitTask->set_ref_count(2);
142 auto set_to_run = std::make_shared<std::atomic<bool>>(
false);
144 q.push([set_to_run, waitTask, iAction]()
mutable {
145 bool expected =
false;
146 if (set_to_run->compare_exchange_strong(expected,
true)) {
151 waitTask->decrement_ref_count();
155 waitTask->wait_for_all();
156 tbb::task::destroy(*waitTask);
159 template <
typename T>
161 auto set_to_run = std::make_shared<std::atomic<bool>>(
false);
163 q.push([&
q, set_to_run, iAction]()
mutable {
164 bool expected =
false;
165 if (set_to_run->compare_exchange_strong(expected,
true)) {
void push(T &&iAction)
asynchronously pushes functor iAction into queue
Resumer(Resumer const &iOther)
unsigned int concurrencyLimit() const
void pushAndWait(T &&iAction)
synchronously pushes functor iAction into queue
Resumer(Resumer &&iOther)
bool resume()
Resumes processing if the queue was paused.
std::vector< SerialTaskQueue > m_queues
SerialTaskQueue * m_queue
Resumer & operator=(Resumer &&iOther)
void pushAndPause(T &&iAction)
asynchronously pushes functor iAction into queue then pause the queue and run iAction ...
LimitedTaskQueue(unsigned int iLimit)
Resumer & operator=(Resumer const &iOther)
friend class LimitedTaskQueue
Resumer(SerialTaskQueue *iQueue)
bool pause()
Pauses processing of additional tasks from the queue.