1 #ifndef FWCore_Concurrency_LimitedTaskQueue_h
2 #define FWCore_Concurrency_LimitedTaskQueue_h
53 void push(
T&& iAction);
90 iOther.m_queue =
nullptr;
113 template <
typename T>
126 template <
typename T>
128 auto set_to_run = std::make_shared<std::atomic<bool>>(
false);
130 q.push([set_to_run, iAction]()
mutable {
131 bool expected =
false;
132 if (set_to_run->compare_exchange_strong(expected,
true)) {
139 template <
typename T>
141 tbb::empty_task* waitTask =
new (tbb::task::allocate_root()) tbb::empty_task;
142 waitTask->set_ref_count(2);
143 auto set_to_run = std::make_shared<std::atomic<bool>>(
false);
145 q.push([set_to_run, waitTask, iAction]()
mutable {
146 bool expected =
false;
147 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)) {