#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 () | |
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_flag | m_taskChosen |
tbb::concurrent_queue< TaskBase * > | m_tasks |
Friends | |
class | TaskBase |
Definition at line 65 of file SerialTaskQueue.h.
|
inline |
Definition at line 68 of file SerialTaskQueue.h.
|
privatedelete |
|
private |
Definition at line 58 of file SerialTaskQueue.cc.
References m_taskChosen, and pickNextTask().
Referenced by edm::SerialTaskQueue::QueuedTask< T >::execute(), and edm::SerialTaskQueue::TaskBase::finishedTask().
|
inline |
Checks to see if the queue has been paused.
Definition at line 78 of file SerialTaskQueue.h.
References m_pauseCount.
|
privatedelete |
|
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 90 of file SerialTaskQueue.h.
References m_pauseCount.
|
private |
Definition at line 64 of file SerialTaskQueue.cc.
References likely, m_pauseCount, m_taskChosen, m_tasks, and edmStreamStallGrapher::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 184 of file SerialTaskQueue.h.
References pushTask().
|
private |
Definition at line 47 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 200 of file SerialTaskQueue.h.
References pushAndGetNextTask().
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 191 of file SerialTaskQueue.h.
|
private |
Definition at line 88 of file SerialTaskQueue.cc.
References pyrootRender::destroy(), likely, and pushAndGetNextTask().
|
private |
Definition at line 39 of file SerialTaskQueue.cc.
References pushAndGetNextTask(), and edmStreamStallGrapher::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 27 of file SerialTaskQueue.cc.
References m_pauseCount, pickNextTask(), and edmStreamStallGrapher::t.
|
friend |
Definition at line 166 of file SerialTaskQueue.h.
|
private |
Definition at line 180 of file SerialTaskQueue.h.
Referenced by isPaused(), pause(), pickNextTask(), and resume().
|
private |
Definition at line 179 of file SerialTaskQueue.h.
Referenced by finishedTask(), and pickNextTask().
|
private |
Definition at line 178 of file SerialTaskQueue.h.
Referenced by pickNextTask(), and pushAndGetNextTask().