#include <WaitingTaskList.h>
Classes | |
struct | WaitNode |
Public Member Functions | |
void | add (tbb::task *) |
Adds task to the waiting list. More... | |
void | doneWaiting () |
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 () | |
Private Member Functions | |
void | announce () |
WaitNode * | createNode (tbb::task *iTask) |
const WaitingTaskList & | operator= (const WaitingTaskList &)=delete |
WaitingTaskList (const WaitingTaskList &)=delete | |
Private Attributes | |
std::atomic< WaitNode * > | m_head |
std::atomic< unsigned int > | m_lastAssignedCacheIndex |
WaitNode * | m_nodeCache |
unsigned int | m_nodeCacheSize |
std::atomic< bool > | m_waiting |
Definition at line 79 of file WaitingTaskList.h.
WaitingTaskList::WaitingTaskList | ( | unsigned int | iInitialSize = 2 | ) |
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.
WaitingTaskList::~WaitingTaskList | ( | ) |
|
privatedelete |
void WaitingTaskList::add | ( | tbb::task * | 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 111 of file WaitingTaskList.cc.
References announce(), createNode(), m_head, m_waiting, and edm::WaitingTaskList::WaitNode::setNextNode().
|
private |
Handles spawning the tasks, safe to call from multiple threads
Definition at line 142 of file WaitingTaskList.cc.
References edm::WaitingTaskList::WaitNode::m_fromCache, m_head, edm::WaitingTaskList::WaitNode::m_task, n, GetRecoTauVFromDQM_MC_cff::next, edm::WaitingTaskList::WaitNode::nextNode(), and lumiQTWidget::t.
Referenced by add(), and doneWaiting().
|
private |
Definition at line 92 of file WaitingTaskList.cc.
References getHLTprescales::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 | ( | ) |
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. To have tasks wait again one must call reset(). Calls to add() and doneWaiting() can safely be done concurrently.
Definition at line 169 of file WaitingTaskList.cc.
References announce(), and m_waiting.
|
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() call be called concurrently with reset().
Definition at line 73 of file WaitingTaskList.cc.
References edm::WaitingTaskList::WaitNode::m_fromCache, m_head, m_lastAssignedCacheIndex, m_nodeCache, m_nodeCacheSize, and m_waiting.
|
private |
Definition at line 144 of file WaitingTaskList.h.
Referenced by add(), announce(), and reset().
|
private |
Definition at line 147 of file WaitingTaskList.h.
Referenced by createNode(), and reset().
|
private |
Definition at line 145 of file WaitingTaskList.h.
Referenced by createNode(), reset(), and ~WaitingTaskList().
|
private |
Definition at line 146 of file WaitingTaskList.h.
Referenced by createNode(), and reset().
|
private |
Definition at line 148 of file WaitingTaskList.h.
Referenced by add(), doneWaiting(), and reset().