CMS 3D CMS Logo

Classes | Public Member Functions | Private Member Functions | Private Attributes

edm::WaitingTaskList Class Reference

#include <WaitingTaskList.h>

List of all members.

Classes

struct  WaitNode

Public Member Functions

void add (tbb::task *)
 Adds task to the waiting list.
void doneWaiting ()
 Signals that the resource is now available and tasks should be spawned.
void reset ()
 Resets access to the resource so that added tasks will wait.
 WaitingTaskList (unsigned int iInitialSize=2)
 Constructor.
 ~WaitingTaskList ()

Private Member Functions

void announce ()
WaitNodecreateNode (tbb::task *iTask)
const WaitingTaskListoperator= (const WaitingTaskList &)
 WaitingTaskList (const WaitingTaskList &)

Private Attributes

std::atomic< WaitNode * > m_head
std::atomic< unsigned int > m_lastAssignedCacheIndex
WaitNodem_nodeCache
unsigned int m_nodeCacheSize
std::atomic< bool > m_waiting

Detailed Description

Definition at line 79 of file WaitingTaskList.h.


Constructor & Destructor Documentation

WaitingTaskList::WaitingTaskList ( unsigned int  iInitialSize = 2)

Constructor.

The WaitingTaskList is initial set to waiting.

Parameters:
[in]iInitialSizespecifies 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.

                                                         :
m_head{0},
edm::WaitingTaskList::~WaitingTaskList ( )
edm::WaitingTaskList::WaitingTaskList ( const WaitingTaskList ) [private]

Member Function Documentation

void edm::WaitingTaskList::add ( tbb::task *  )

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.

void edm::WaitingTaskList::announce ( ) [private]

Handles spawning the tasks, safe to call from multiple threads

WaitNode* edm::WaitingTaskList::createNode ( tbb::task *  iTask) [private]
void edm::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.

const WaitingTaskList& edm::WaitingTaskList::operator= ( const WaitingTaskList ) [private]
void edm::WaitingTaskList::reset ( )

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().


Member Data Documentation

std::atomic<WaitNode*> edm::WaitingTaskList::m_head [private]

Definition at line 144 of file WaitingTaskList.h.

std::atomic<unsigned int> edm::WaitingTaskList::m_lastAssignedCacheIndex [private]

Definition at line 147 of file WaitingTaskList.h.

Definition at line 145 of file WaitingTaskList.h.

unsigned int edm::WaitingTaskList::m_nodeCacheSize [private]

Definition at line 146 of file WaitingTaskList.h.

std::atomic<bool> edm::WaitingTaskList::m_waiting [private]

Definition at line 148 of file WaitingTaskList.h.