#include <SerialTaskQueue.h>
Classes | |
class | QueuedTask |
class | TaskBase |
Public Member Functions | |
bool | isPaused () const |
Checks to see if the queue has been paused. More... | |
bool | pause () |
Pauses processing of additional tasks from the queue. More... | |
template<typename T > | |
void | push (const T &iAction) |
asynchronously pushes functor iAction into queue More... | |
template<typename T > | |
tbb::task * | pushAndGetNextTaskToRun (const T &iAction) |
asynchronously pushes functor iAction into queue and finds next task to execute More... | |
template<typename T > | |
void | pushAndWait (const T &iAction) |
synchronously pushes functor iAction into queue More... | |
bool | resume () |
Resumes processing if the queue was paused. More... | |
SerialTaskQueue () | |
SerialTaskQueue (SerialTaskQueue &&iOther) | |
~SerialTaskQueue () | |
Private Member Functions | |
tbb::task * | finishedTask () |
const SerialTaskQueue & | operator= (const SerialTaskQueue &)=delete |
TaskBase * | pickNextTask () |
tbb::task * | pushAndGetNextTask (TaskBase *) |
void | pushAndWait (tbb::empty_task *iWait, TaskBase *) |
void | pushTask (TaskBase *) |
SerialTaskQueue (const SerialTaskQueue &)=delete | |
Private Attributes | |
std::atomic< unsigned long > | m_pauseCount |
std::atomic< bool > | m_taskChosen |
tbb::concurrent_queue< TaskBase * > | m_tasks |
Friends | |
class | TaskBase |
Definition at line 66 of file SerialTaskQueue.h.
|
inline |
Definition at line 69 of file SerialTaskQueue.h.
Referenced by pause().
|
inline |
Definition at line 74 of file SerialTaskQueue.h.
References m_taskChosen, m_tasks, and ~SerialTaskQueue().
SerialTaskQueue::~SerialTaskQueue | ( | ) |
Definition at line 26 of file SerialTaskQueue.cc.
References isPaused(), m_taskChosen, m_tasks, or, and pushAndWait().
Referenced by SerialTaskQueue().
|
privatedelete |
|
private |
Definition at line 68 of file SerialTaskQueue.cc.
References m_taskChosen, and pickNextTask().
Referenced by edm::SerialTaskQueue::TaskBase::finishedTask().
|
inline |
Checks to see if the queue has been paused.
Definition at line 88 of file SerialTaskQueue.h.
References m_pauseCount.
Referenced by ~SerialTaskQueue().
|
privatedelete |
Referenced by pause().
|
inline |
Pauses processing of additional tasks from the queue.
Any task already running will not be paused however once that running task finishes no further tasks will be started. Multiple calls to pause() are allowed, however each call to pause() must be balanced by a call to resume().
Definition at line 100 of file SerialTaskQueue.h.
References m_pauseCount, operator=(), push(), pushAndGetNextTaskToRun(), pushAndWait(), resume(), and SerialTaskQueue().
Referenced by edm::EventProcessor::beginLumiAsync(), and edm::LimitedTaskQueue::Resumer::Resumer().
|
private |
Definition at line 74 of file SerialTaskQueue.cc.
References likely, m_pauseCount, m_taskChosen, m_tasks, and lumiQTWidget::t.
Referenced by finishedTask(), pushAndGetNextTask(), and resume().
void SerialTaskQueue::push | ( | const T & | iAction | ) |
asynchronously pushes functor iAction into queue
The function will return immediately and iAction will either process concurrently with the calling thread or wait until the protected resource becomes available or until a CPU becomes available.
[in] | iAction | Must be a functor that takes no arguments and return no values. |
Definition at line 194 of file SerialTaskQueue.h.
References pushTask().
Referenced by edm::EventProcessor::beginLumiAsync(), and pause().
|
private |
Definition at line 57 of file SerialTaskQueue.cc.
References likely, m_tasks, and pickNextTask().
Referenced by pushAndGetNextTaskToRun(), pushAndWait(), and pushTask().
tbb::task * SerialTaskQueue::pushAndGetNextTaskToRun | ( | const T & | iAction | ) |
asynchronously pushes functor iAction into queue and finds next task to execute
This function is useful if you are accessing the SerialTaskQueue for the execute() method of a TBB task and want to efficiently schedule the next task from the queue. In that case you can take the return value and return it directly from your execute() method. The function will return immediately and not wait for iAction to run.
[in] | iAction | Must be a functor that takes no arguments and return no values. |
Definition at line 210 of file SerialTaskQueue.h.
References pushAndGetNextTask().
Referenced by pause().
void SerialTaskQueue::pushAndWait | ( | const T & | iAction | ) |
synchronously pushes functor iAction into queue
The function will wait until iAction has completed before returning. If another task is already running on the queue, the system is allowed to find another TBB task to execute while waiting for the iAction to finish. In that way the core is not idled while waiting.
[in] | iAction | Must be a functor that takes no arguments and return no values. |
Definition at line 201 of file SerialTaskQueue.h.
Referenced by pause(), and ~SerialTaskQueue().
|
private |
Definition at line 100 of file SerialTaskQueue.cc.
References pyrootRender::destroy(), likely, and pushAndGetNextTask().
|
private |
Definition at line 49 of file SerialTaskQueue.cc.
References pushAndGetNextTask(), and lumiQTWidget::t.
Referenced by push().
bool SerialTaskQueue::resume | ( | ) |
Resumes processing if the queue was paused.
Multiple calls to resume() are allowed if there were multiple calls to pause(). Only when we reach as many resume() calls as pause() calls will the queue restart.
Definition at line 37 of file SerialTaskQueue.cc.
References m_pauseCount, pickNextTask(), and lumiQTWidget::t.
Referenced by edm::EventProcessor::globalEndLumiAsync(), edm::LimitedTaskQueue::Resumer::operator=(), pause(), and edm::Worker::RunModuleTask< T >::EnableQueueGuard::~EnableQueueGuard().
|
friend |
Definition at line 176 of file SerialTaskQueue.h.
|
private |
Definition at line 190 of file SerialTaskQueue.h.
Referenced by isPaused(), pause(), pickNextTask(), and resume().
|
private |
Definition at line 189 of file SerialTaskQueue.h.
Referenced by finishedTask(), pickNextTask(), SerialTaskQueue(), and ~SerialTaskQueue().
|
private |
Definition at line 188 of file SerialTaskQueue.h.
Referenced by pickNextTask(), pushAndGetNextTask(), SerialTaskQueue(), and ~SerialTaskQueue().