#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 67 of file SerialTaskQueue.h.
|
inline |
Definition at line 69 of file SerialTaskQueue.h.
|
inline |
Definition at line 71 of file SerialTaskQueue.h.
References cms::cuda::assert(), m_taskChosen, and m_tasks.
SerialTaskQueue::~SerialTaskQueue | ( | ) |
Definition at line 26 of file SerialTaskQueue.cc.
References isPaused(), m_taskChosen, m_tasks, or, and pushAndWait().
|
privatedelete |
|
private |
Definition at line 63 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 84 of file SerialTaskQueue.h.
References m_pauseCount.
Referenced by ~SerialTaskQueue().
|
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 96 of file SerialTaskQueue.h.
References m_pauseCount.
Referenced by edm::EventProcessor::beginLumiAsync(), and edm::LimitedTaskQueue::Resumer::Resumer().
|
private |
Definition at line 68 of file SerialTaskQueue.cc.
References LIKELY, m_pauseCount, m_taskChosen, m_tasks, and OrderedSet::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 187 of file SerialTaskQueue.h.
References pushTask(), and edm::SerialTaskQueue::TaskBase::setQueue().
Referenced by edm::EventProcessor::beginLumiAsync().
|
private |
Definition at line 53 of file SerialTaskQueue.cc.
References LIKELY, m_tasks, pickNextTask(), and TrackValidation_cff::task.
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 203 of file SerialTaskQueue.h.
References pushAndGetNextTask(), and edm::SerialTaskQueue::TaskBase::setQueue().
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 194 of file SerialTaskQueue.h.
References edm::SerialTaskQueue::TaskBase::setQueue().
Referenced by ~SerialTaskQueue().
|
private |
|
private |
Definition at line 46 of file SerialTaskQueue.cc.
References pushAndGetNextTask(), OrderedSet::t, and TrackValidation_cff::task.
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 35 of file SerialTaskQueue.cc.
References m_pauseCount, pickNextTask(), OrderedSet::t, and TrackValidation_cff::task.
Referenced by edm::EventProcessor::globalEndLumiAsync(), edm::LimitedTaskQueue::Resumer::operator=(), and edm::Worker::RunModuleTask< T >::EnableQueueGuard::~EnableQueueGuard().
|
friend |
Definition at line 170 of file SerialTaskQueue.h.
|
private |
Definition at line 183 of file SerialTaskQueue.h.
Referenced by isPaused(), pause(), pickNextTask(), and resume().
|
private |
Definition at line 182 of file SerialTaskQueue.h.
Referenced by finishedTask(), pickNextTask(), SerialTaskQueue(), and ~SerialTaskQueue().
|
private |
Definition at line 181 of file SerialTaskQueue.h.
Referenced by pickNextTask(), pushAndGetNextTask(), SerialTaskQueue(), and ~SerialTaskQueue().