#include <WaitingTaskList.h>
Classes | |
struct | WaitNode |
Public Member Functions | |
void | add (tbb::task_group *, WaitingTask *) |
Adds task to the waiting list. More... | |
void | add (WaitingTaskHolder) |
Adds task to the waiting list. More... | |
void | doneWaiting (std::exception_ptr iPtr) |
Signals that the resource is now available and tasks should be spawned. More... | |
const WaitingTaskList & | operator= (const WaitingTaskList &)=delete |
void | presetTaskAsFailed (std::exception_ptr iExcept) |
void | reset () |
Resets access to the resource so that added tasks will wait. More... | |
WaitingTaskList (const WaitingTaskList &)=delete | |
WaitingTaskList (unsigned int iInitialSize=2) | |
Constructor. More... | |
~WaitingTaskList ()=default | |
Private Member Functions | |
void | announce () |
WaitNode * | createNode (tbb::task_group *iGroup, WaitingTask *iTask) |
Private Attributes | |
std::exception_ptr | m_exceptionPtr |
std::atomic< WaitNode * > | m_head |
std::atomic< unsigned int > | m_lastAssignedCacheIndex |
std::unique_ptr< WaitNode[]> | m_nodeCache |
unsigned int | m_nodeCacheSize |
std::atomic< bool > | m_waiting |
Definition at line 84 of file WaitingTaskList.h.
|
explicit |
Constructor.
The WaitingTaskList is initial set to waiting.
[in] | iInitialSize | specifies the initial size of the cache used to hold waiting tasks. The value is only useful for optimization as the object can resize itself. |
Definition at line 38 of file WaitingTaskList.cc.
|
delete |
|
default |
void WaitingTaskList::add | ( | tbb::task_group * | iGroup, |
WaitingTask * | iTask | ||
) |
Adds task to the waiting list.
If doneWaiting() has already been called then the added task will immediately be run. If that is not the case then the task will be held until doneWaiting() is called and will then be run. Calls to add() and doneWaiting() can safely be done concurrently.
Definition at line 125 of file WaitingTaskList.cc.
References announce(), createNode(), edm::TaskBase::decrement_ref_count(), edm::WaitingTask::dependentTaskFailed(), edm::TaskBase::execute(), edm::TaskBase::increment_ref_count(), m_exceptionPtr, m_head, m_waiting, alignCSCRings::s, edm::WaitingTaskList::WaitNode::setNextNode(), and UNLIKELY.
Referenced by edm::Worker::callWhenDoneAsync(), edm::eventsetup::EventSetupRecordIOVQueue::checkForNewIOVs(), edm::Worker::doWorkAsync(), edm::Worker::doWorkNoPrefetchingAsync(), edm::eventsetup::EventSetupRecordIOVQueue::endIOVAsync(), edm::eventsetup::Callback< T, TReturn, TRecord, TDecorator >::prefetchAsync(), edm::DelayedReaderInputProductResolver::prefetchAsync_(), edm::PuttableProductResolver::prefetchAsync_(), edm::UnscheduledProductResolver::prefetchAsync_(), edm::SwitchProducerProductResolver::prefetchAsync_(), edm::SwitchAliasProductResolver::prefetchAsync_(), edm::NoProcessProductResolver::prefetchAsync_(), edm::eventsetup::ESSourceDataProxyBase::prefetchAsyncImpl(), edm::eventsetup::DataProxyTemplate< RecordT, DataT >::prefetchAsyncImpl(), edm::Path::processOneOccurrenceAsync(), counter.Counter::register(), SequenceTypes.Task::remove(), SequenceTypes.Task::replace(), and edm::eventsetup::EventSetupRecordIOVQueue::startNewIOVAsync().
void WaitingTaskList::add | ( | WaitingTaskHolder | iTask | ) |
Adds task to the waiting list.
Calls to add() and doneWaiting() can safely be done concurrently.
Definition at line 92 of file WaitingTaskList.cc.
References announce(), createNode(), edm::WaitingTaskHolder::doneWaiting(), edm::WaitingTaskHolder::group(), m_exceptionPtr, m_head, m_waiting, edm::WaitingTaskHolder::release_no_decrement(), edm::WaitingTaskList::WaitNode::setNextNode(), and TrackValidation_cff::task.
Referenced by counter.Counter::register(), SequenceTypes.Task::remove(), and SequenceTypes.Task::replace().
|
private |
Handles running the tasks, safe to call from multiple threads
Definition at line 177 of file WaitingTaskList.cc.
References g, m_exceptionPtr, m_head, dqmiodumpmetadata::n, GetRecoTauVFromDQM_MC_cff::next, alignCSCRings::s, submitPVValidationJobs::t, and UNLIKELY.
Referenced by add(), and doneWaiting().
|
private |
Definition at line 72 of file WaitingTaskList.cc.
References edm::WaitingTaskList::WaitNode::m_fromCache, edm::WaitingTaskList::WaitNode::m_group, m_lastAssignedCacheIndex, edm::WaitingTaskList::WaitNode::m_next, m_nodeCache, m_nodeCacheSize, and edm::WaitingTaskList::WaitNode::m_task.
Referenced by add().
void WaitingTaskList::doneWaiting | ( | std::exception_ptr | iPtr | ) |
Signals that the resource is now available and tasks should be spawned.
The owner of the resource calls this function to allow the waiting tasks to start accessing it. If the task fails, a non 'null' std::exception_ptr should be used. To have tasks wait again one must call reset(). Calls to add() and doneWaiting() can safely be done concurrently.
Definition at line 212 of file WaitingTaskList.cc.
References announce(), m_exceptionPtr, and m_waiting.
Referenced by edm::Worker::doWorkNoPrefetchingAsync(), edm::Path::finished(), edm::DelayedReaderInputProductResolver::prefetchAsync_(), edm::PuttableProductResolver::prefetchAsync_(), edm::UnscheduledProductResolver::prefetchAsync_(), edm::SwitchProducerProductResolver::prefetchAsync_(), edm::SwitchAliasProductResolver::prefetchAsync_(), edm::eventsetup::ESSourceDataProxyBase::prefetchAsyncImpl(), edm::eventsetup::DataProxyTemplate< RecordT, DataT >::prefetchAsyncImpl(), edm::Worker::prePrefetchSelectionAsync(), edm::PuttableProductResolver::putProduct(), edm::SwitchProducerProductResolver::putProduct(), edm::LuminosityBlockProcessingStatus::resetResources(), edm::Worker::runModuleAfterAsyncPrefetch(), edm::eventsetup::Callback< T, TReturn, TRecord, TDecorator >::runProducerAsync(), edm::NoProcessProductResolver::setCache(), edm::Worker::skipOnPath(), edm::eventsetup::EventSetupRecordIOVQueue::startNewIOVAsync(), edm::eventsetup::synchronousEventSetupForInstance(), and edm::LuminosityBlockProcessingStatus::~LuminosityBlockProcessingStatus().
|
delete |
void WaitingTaskList::presetTaskAsFailed | ( | std::exception_ptr | iExcept | ) |
Use in the case where you need to inform the parent task of a failure before some other child task which may be run later reports a different, but related failure. You must later call doneWaiting with same exception later in the same thread.
Definition at line 163 of file WaitingTaskList.cc.
References edm::WaitingTask::dependentTaskFailed(), m_head, edm::WaitingTaskList::WaitNode::m_task, m_waiting, GetRecoTauVFromDQM_MC_cff::next, and edm::WaitingTaskList::WaitNode::nextNode().
Referenced by edm::Path::workerFinished().
void WaitingTaskList::reset | ( | void | ) |
Resets access to the resource so that added tasks will wait.
The owner of the resouce calls reset() to make tasks wait. Calling reset() is NOT thread safe. The system must guarantee that no tasks are using the resource when reset() is called and neither add() nor doneWaiting() can be called concurrently with reset().
Definition at line 53 of file WaitingTaskList.cc.
References cms::cuda::assert(), m_exceptionPtr, m_head, m_lastAssignedCacheIndex, m_nodeCache, m_nodeCacheSize, and m_waiting.
Referenced by edm::eventsetup::EventSetupRecordIOVQueue::endIOVAsync(), edm::eventsetup::ESSourceDataProxyBase::invalidateCache(), edm::eventsetup::DataProxyTemplate< RecordT, DataT >::invalidateCache(), edm::eventsetup::Callback< T, TReturn, TRecord, TDecorator >::newRecordComing(), edm::Path::processOneOccurrenceAsync(), edm::Worker::reset(), edm::DelayedReaderInputProductResolver::resetProductData_(), edm::PuttableProductResolver::resetProductData_(), edm::UnscheduledProductResolver::resetProductData_(), edm::SwitchBaseProductResolver::resetProductData_(), and edm::NoProcessProductResolver::resetProductData_().
|
private |
Definition at line 157 of file WaitingTaskList.h.
Referenced by add(), announce(), doneWaiting(), and reset().
|
private |
Definition at line 155 of file WaitingTaskList.h.
Referenced by add(), announce(), presetTaskAsFailed(), and reset().
|
private |
Definition at line 159 of file WaitingTaskList.h.
Referenced by createNode(), and reset().
|
private |
Definition at line 156 of file WaitingTaskList.h.
Referenced by createNode(), and reset().
|
private |
Definition at line 158 of file WaitingTaskList.h.
Referenced by createNode(), and reset().
|
private |
Definition at line 160 of file WaitingTaskList.h.
Referenced by add(), doneWaiting(), presetTaskAsFailed(), and reset().