The Gaudi Framework  v32r2 (46d42edc)
SerialTaskQueue.cpp
Go to the documentation of this file.
1 /*
2  * SerialTaskQueue.cpp
3  *
4  * @date 2012-10-21
5  * @author Marco Clemencic
6  */
7 
9 
10 namespace Gaudi {
11 
13 
15 
17 
19  m_queue.push( new SerialWorkItem( item, this ) );
20  if ( ++m_count == 1 ) i_startNextItem();
21  }
22 
24  if ( --m_count != 0 ) i_startNextItem();
25  }
26 
27  void SerialTaskQueue::wait() const {
28  // wait until the queue is empty and all the tasks are completed
29  while ( ( !m_queue.empty() ) || m_count ) {}
30  }
31 
33  SerialWorkItem* item = 0;
34  m_queue.try_pop( item );
35  tbb::task::enqueue( *new ( tbb::task::allocate_root() ) SerialWorkItemRunner( item ) );
36  }
37 
38 } /* namespace Gaudi */
Base class for the task to be executed by the serial queue.
tbb::concurrent_queue< SerialWorkItem * > m_queue
Queue of the tasks to be executed.
Wrapper for the WorkItem class for internal concurrency bookkeeping.
SerialTaskQueue()
Default constructor.
void wait() const
Block until all the currently enqueued tasks are completed.
virtual ~SerialTaskQueue()
Block until all the enqueued tasks are completed.
void add(WorkItem *item)
Enqueue a WorkItem for execution.
Helper class to wrap a SerialWorkItem in a tbb::task.
void noteCompletion()
Method used by the tasks to trigger the execution of the next task in the queue.
Header file for std:chrono::duration-based Counters.
Definition: __init__.py:1
std::atomic< int > m_count
Counter of the currently running tasks.