1 #ifndef FWCore_Concurrency_LimitedTaskQueue_h
2 #define FWCore_Concurrency_LimitedTaskQueue_h
55 void push(
T&& iAction);
92 iOther.m_queue =
nullptr;
115 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)) {
150 waitTask->decrement_ref_count();
154 waitTask->wait_for_all();
155 tbb::task::destroy(*waitTask);
158 template <
typename T>
160 auto set_to_run = std::make_shared<std::atomic<bool>>(
false);
162 q.push([&
q, set_to_run, iAction]()
mutable {
163 bool expected =
false;
164 if (set_to_run->compare_exchange_strong(expected,
true)) {