test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
WaitingTaskList.h
Go to the documentation of this file.
1 #ifndef FWCore_Concurrency_WaitingTaskList_h
2 #define FWCore_Concurrency_WaitingTaskList_h
3 // -*- C++ -*-
4 //
5 // Package: Concurrency
6 // Class : WaitingTaskList
7 //
62 //
63 // Original Author: Chris Jones
64 // Created: Thu Feb 21 13:46:31 CST 2013
65 // $Id$
66 //
67 
68 // system include files
69 #include <atomic>
70 
71 // user include files
72 
73 // forward declarations
74 namespace tbb {
75  class task;
76 }
77 
78 namespace edm {
80  {
81 
82  public:
84 
88  WaitingTaskList(unsigned int iInitialSize = 2);
90 
91  // ---------- member functions ---------------------------
92 
94 
99  void add(tbb::task*);
100 
102 
107  void doneWaiting();
108 
110 
115  void reset();
116 
117  private:
118  WaitingTaskList(const WaitingTaskList&) = delete; // stop default
119  const WaitingTaskList& operator=(const WaitingTaskList&) = delete; // stop default
120 
124  void announce();
125 
126  struct WaitNode {
127  tbb::task* m_task;
128  std::atomic<WaitNode*> m_next;
130 
131  void setNextNode(WaitNode* iNext){
132  m_next = iNext;
133  }
134 
135  WaitNode* nextNode() const {
136  return m_next;
137  }
138  };
139 
140  WaitNode* createNode(tbb::task* iTask);
141 
142 
143  // ---------- member data --------------------------------
144  std::atomic<WaitNode*> m_head;
146  unsigned int m_nodeCacheSize;
147  std::atomic<unsigned int> m_lastAssignedCacheIndex;
148  std::atomic<bool> m_waiting;
149  };
150 }
151 
152 #endif
WaitNode * createNode(tbb::task *iTask)
std::atomic< bool > m_waiting
std::atomic< unsigned int > m_lastAssignedCacheIndex
std::atomic< WaitNode * > m_head
void reset()
Resets access to the resource so that added tasks will wait.
std::atomic< WaitNode * > m_next
void add(tbb::task *)
Adds task to the waiting list.
WaitingTaskList(unsigned int iInitialSize=2)
Constructor.
void doneWaiting()
Signals that the resource is now available and tasks should be spawned.
unsigned int m_nodeCacheSize
void setNextNode(WaitNode *iNext)
const WaitingTaskList & operator=(const WaitingTaskList &)=delete