1 #ifndef FWCore_Concurrency_LimitedTaskQueue_h 2 #define FWCore_Concurrency_LimitedTaskQueue_h 56 void push(
T&& iAction);
79 iOther.m_queue =
nullptr;
95 iOther.m_queue =
nullptr;
131 auto set_to_run = std::make_shared<std::atomic<bool>>(
false);
133 q.push([set_to_run,iAction]()
mutable{
134 bool expected =
false;
135 if(set_to_run->compare_exchange_strong(expected,
true)) {
144 tbb::empty_task* waitTask =
new (tbb::task::allocate_root()) tbb::empty_task;
145 waitTask->set_ref_count(2);
146 auto set_to_run = std::make_shared<std::atomic<bool>>(
false);
148 q.push([set_to_run,waitTask,iAction]()
mutable{
149 bool expected =
false;
150 if(set_to_run->compare_exchange_strong(expected,
true)) {
154 waitTask->decrement_ref_count();
158 waitTask->wait_for_all();
164 auto set_to_run = std::make_shared<std::atomic<bool>>(
false);
166 q.push([&
q,set_to_run,iAction]()
mutable{
167 bool expected =
false;
168 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.