CMS 3D CMS Logo

WaitingTaskHolder.h
Go to the documentation of this file.
1 #ifndef FWCore_Concurrency_WaitingTaskHolder_h
2 #define FWCore_Concurrency_WaitingTaskHolder_h
3 // -*- C++ -*-
4 //
5 // Package: FWCore/Concurrency
6 // Class : WaitingTaskHolder
7 //
16 //
17 // Original Author: FWCore
18 // Created: Fri, 18 Nov 2016 20:30:42 GMT
19 //
20 
21 // system include files
22 #include <cassert>
23 
24 // user include files
26 
27 // forward declarations
28 
29 namespace edm {
31  {
32 
33  public:
35  m_task(nullptr) {}
36 
38  m_task(iTask)
39  {m_task->increment_ref_count();}
41  if(m_task) {
42  doneWaiting(std::exception_ptr{});
43  }
44  }
45 
47  m_task(iHolder.m_task) {
48  m_task->increment_ref_count();
49  }
50 
52  m_task(iOther.m_task) {
53  iOther.m_task = nullptr;
54  }
55 
57  WaitingTaskHolder tmp(iRHS);
58  std::swap(m_task, tmp.m_task);
59  return *this;
60  }
61 
62  // ---------- const member functions ---------------------
63  bool taskHasFailed() const { return m_task->exceptionPtr() != nullptr; }
64 
65  // ---------- static member functions --------------------
66 
67  // ---------- member functions ---------------------------
68  void doneWaiting(std::exception_ptr iExcept) {
69  if(iExcept) {
70  m_task->dependentTaskFailed(iExcept);
71  }
72  if(0==m_task->decrement_ref_count()){
73  tbb::task::spawn(*m_task);
74  }
75  m_task = nullptr;
76  }
77 
78  private:
79 
80  // ---------- member data --------------------------------
82  };
83 }
84 
85 #endif
#define nullptr
WaitingTaskHolder & operator=(const WaitingTaskHolder &iRHS)
WaitingTaskHolder(WaitingTaskHolder &&iOther)
void dependentTaskFailed(std::exception_ptr iPtr)
Called if waited for task failed.
Definition: WaitingTask.h:64
void doneWaiting(std::exception_ptr iExcept)
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
WaitingTaskHolder(const WaitingTaskHolder &iHolder)
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
HLT enums.
WaitingTaskHolder(edm::WaitingTask *iTask)
std::exception_ptr const * exceptionPtr() const
Returns exception thrown by dependent task.
Definition: WaitingTask.h:54