#include <WaitingTaskList.h>
Classes | |
struct | WaitNode |
Public Member Functions | |
void | add (WaitingTask *) |
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... | |
void | reset () |
Resets access to the resource so that added tasks will wait. More... | |
WaitingTaskList (unsigned int iInitialSize=2) | |
Constructor. More... | |
~WaitingTaskList ()=default | |
Private Member Functions | |
void | announce () |
WaitNode * | createNode (WaitingTask *iTask) |
const WaitingTaskList & | operator= (const WaitingTaskList &)=delete |
WaitingTaskList (const WaitingTaskList &)=delete | |
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 102 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 35 of file WaitingTaskList.cc.
|
default |
|
privatedelete |
void WaitingTaskList::add | ( | WaitingTask * | iTask | ) |
Adds task to the waiting list.
If doneWaiting() has already been called then the added task will immediately be spawned. If that is not the case then the task will be held until doneWaiting() is called and will then be spawned. Calls to add() and doneWaiting() can safely be done concurrently.
Definition at line 92 of file WaitingTaskList.cc.
References announce(), createNode(), edm::WaitingTask::dependentTaskFailed(), m_exceptionPtr, m_head, m_waiting, and edm::WaitingTaskList::WaitNode::setNextNode().
Referenced by edm::Worker::callWhenDoneAsync(), edm::Worker::doWork(), edm::Worker::doWorkAsync(), edm::InputProductResolver::prefetchAsync_(), edm::PuttableProductResolver::prefetchAsync_(), edm::UnscheduledProductResolver::prefetchAsync_(), edm::NoProcessProductResolver::prefetchAsync_(), edm::Path::processOneOccurrenceAsync(), and counter.Counter::register().
|
private |
Handles spawning the tasks, safe to call from multiple threads
Definition at line 126 of file WaitingTaskList.cc.
References m_exceptionPtr, edm::WaitingTaskList::WaitNode::m_fromCache, m_head, edm::WaitingTaskList::WaitNode::m_task, gen::n, GetRecoTauVFromDQM_MC_cff::next, edm::WaitingTaskList::WaitNode::nextNode(), and t.
Referenced by add(), and doneWaiting().
|
private |
Definition at line 73 of file WaitingTaskList.cc.
References cmsHarvester::index, edm::WaitingTaskList::WaitNode::m_fromCache, 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 156 of file WaitingTaskList.cc.
References announce(), m_exceptionPtr, and m_waiting.
Referenced by edm::Worker::doWork(), edm::Worker::doWorkAsync(), edm::Path::finished(), edm::InputProductResolver::prefetchAsync_(), edm::PuttableProductResolver::prefetchAsync_(), edm::UnscheduledProductResolver::prefetchAsync_(), edm::PuttableProductResolver::putProduct_(), edm::Worker::runModuleAfterAsyncPrefetch(), edm::NoProcessProductResolver::setCache(), and edm::Worker::skipOnPath().
|
privatedelete |
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 52 of file WaitingTaskList.cc.
References assert(), m_exceptionPtr, m_head, m_lastAssignedCacheIndex, m_nodeCache, m_nodeCacheSize, and m_waiting.
Referenced by edm::Path::processOneOccurrenceAsync(), edm::Worker::reset(), edm::InputProductResolver::resetProductData_(), edm::PuttableProductResolver::resetProductData_(), edm::UnscheduledProductResolver::resetProductData_(), and edm::NoProcessProductResolver::resetProductData_().
|
private |
Definition at line 170 of file WaitingTaskList.h.
Referenced by add(), announce(), doneWaiting(), and reset().
|
private |
Definition at line 168 of file WaitingTaskList.h.
Referenced by add(), announce(), and reset().
|
private |
Definition at line 172 of file WaitingTaskList.h.
Referenced by createNode(), and reset().
|
private |
Definition at line 169 of file WaitingTaskList.h.
Referenced by createNode(), and reset().
|
private |
Definition at line 171 of file WaitingTaskList.h.
Referenced by createNode(), and reset().
|
private |
Definition at line 173 of file WaitingTaskList.h.
Referenced by add(), doneWaiting(), and reset().