All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 
8 #include "GaudiKernel/SerialTaskQueue.h"
9 
10 namespace Gaudi {
11 
13  }
14 
16  wait();
17  }
18 
20  }
21 
23  m_queue.push(new SerialWorkItem(item, this));
24  if (++m_count == 1)
26  }
27 
29  if (--m_count!=0)
31  }
32 
33  void SerialTaskQueue::wait() const {
34  // wait until the queue is empty and all the tasks are completed
35  while((!m_queue.empty()) || m_count) {}
36  }
37 
39  SerialWorkItem *item = 0;
40  m_queue.try_pop(item);
41  tbb::task::enqueue(*new(tbb::task::allocate_root()) SerialWorkItemRunner(item));
42  }
43 
44 } /* namespace Gaudi */
std::atomic< int > m_count
Counter of the currently running tasks.
Base class for the task to be executed by the serial queue.
Wrapper for the WorkItem class for internal concurrency bookkeeping.
void wait() const
Block until all the currently enqueued tasks are completed.
SerialTaskQueue()
Default constructor.
virtual ~SerialTaskQueue()
Block until all the enqueued tasks are completed.
tbb::concurrent_queue< SerialWorkItem * > m_queue
Queue of the tasks to be executed.
void add(WorkItem *item)
Enqueue a WorkItem for execution.
tuple item
print s1,s2
Definition: ana.py:146
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.
Helper functions to set/get the application return code.
Definition: __init__.py:1