CMS 3D CMS Logo

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 //
67 //
68 // Original Author: Chris Jones
69 // Created: Thu Feb 21 13:46:31 CST 2013
70 // $Id$
71 //
72 
73 // system include files
74 #include <atomic>
75 
76 // user include files
79 
80 // forward declarations
81 
82 namespace edm {
83  class EmptyWaitingTask : public WaitingTask {
84  public:
85  EmptyWaitingTask() = default;
86 
87  tbb::task* execute() override { return nullptr;}
88  };
89 
90  namespace waitingtask {
91  struct TaskDestroyer {
92  void operator()(tbb::task* iTask) const {
93  tbb::task::destroy(*iTask);
94  }
95  };
96  }
98  inline std::unique_ptr<edm::EmptyWaitingTask, waitingtask::TaskDestroyer> make_empty_waiting_task() {
99  return std::unique_ptr<edm::EmptyWaitingTask, waitingtask::TaskDestroyer>( new (tbb::task::allocate_root()) edm::EmptyWaitingTask{});
100  }
101 
103  {
104 
105  public:
107 
111  explicit WaitingTaskList(unsigned int iInitialSize = 2);
112  ~WaitingTaskList() = default;
113 
114  // ---------- member functions ---------------------------
115 
117 
122  void add(WaitingTask*);
123 
125 
131  void doneWaiting(std::exception_ptr iPtr);
132 
134 
139  void reset();
140 
141  private:
142  WaitingTaskList(const WaitingTaskList&) = delete; // stop default
143  const WaitingTaskList& operator=(const WaitingTaskList&) = delete; // stop default
144 
148  void announce();
149 
150  struct WaitNode {
152  std::atomic<WaitNode*> m_next;
154 
155  void setNextNode(WaitNode* iNext){
156  m_next = iNext;
157  }
158 
159  WaitNode* nextNode() const {
160  return m_next;
161  }
162  };
163 
165 
166 
167  // ---------- member data --------------------------------
168  std::atomic<WaitNode*> m_head;
169  std::unique_ptr<WaitNode[]> m_nodeCache;
170  CMS_THREAD_GUARD(m_waiting) std::exception_ptr m_exceptionPtr;
171  unsigned int m_nodeCacheSize;
172  std::atomic<unsigned int> m_lastAssignedCacheIndex;
173  std::atomic<bool> m_waiting;
174  };
175 }
176 
177 #endif
tbb::task * execute() override
def destroy(e)
Definition: pyrootRender.py:13
std::atomic< WaitNode * > m_head
std::atomic< WaitNode * > m_next
void operator()(tbb::task *iTask) const
std::unique_ptr< WaitNode[]> m_nodeCache
std::unique_ptr< edm::EmptyWaitingTask, waitingtask::TaskDestroyer > make_empty_waiting_task()
Create an EmptyWaitingTask which will properly be destroyed.
def createNode(xml_doc, node_name, values={}, parent=None)
#define CMS_THREAD_GUARD(_var_)
EmptyWaitingTask()=default
void add(std::map< std::string, TH1 * > &h, TH1 *hist)
friend class WaitingTaskList
Definition: WaitingTask.h:39
HLT enums.
void setNextNode(WaitNode *iNext)
void reset(double vett[256])
Definition: TPedValues.cc:11