CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
edm::WaitingTaskWithArenaHolder Class Reference

#include <WaitingTaskWithArenaHolder.h>

Public Member Functions

void doneWaiting (std::exception_ptr iExcept)
 
WaitingTaskHolder makeWaitingTaskHolderAndRelease ()
 
WaitingTaskWithArenaHolderoperator= (const WaitingTaskWithArenaHolder &iRHS)
 
WaitingTaskWithArenaHolderoperator= (WaitingTaskWithArenaHolder &&iRHS)
 
 WaitingTaskWithArenaHolder ()
 
 WaitingTaskWithArenaHolder (WaitingTask *iTask)
 
 WaitingTaskWithArenaHolder (WaitingTaskWithArenaHolder const &iHolder)
 
 WaitingTaskWithArenaHolder (WaitingTaskWithArenaHolder &&iOther)
 
 ~WaitingTaskWithArenaHolder ()
 

Private Attributes

std::shared_ptr< tbb::task_arena > m_arena
 
WaitingTaskm_task
 

Detailed Description

Description: This holds a WaitingTask and can be passed to something the WaitingTask is waiting for. That allows that something to call doneWaiting to let the WaitingTask know it can run. The use of the arena allows one to call doneWaiting from a thread external to the arena where the task should run. The external thread might be a non-TBB thread.

Definition at line 32 of file WaitingTaskWithArenaHolder.h.

Constructor & Destructor Documentation

edm::WaitingTaskWithArenaHolder::WaitingTaskWithArenaHolder ( )

Definition at line 15 of file WaitingTaskWithArenaHolder.cc.

15 : m_task(nullptr) {}
edm::WaitingTaskWithArenaHolder::WaitingTaskWithArenaHolder ( WaitingTask iTask)
explicit

Definition at line 20 of file WaitingTaskWithArenaHolder.cc.

References m_task.

21  : m_task(iTask), m_arena(std::make_shared<tbb::task_arena>(tbb::task_arena::attach())) {
22  m_task->increment_ref_count();
23  }
std::shared_ptr< tbb::task_arena > m_arena
edm::WaitingTaskWithArenaHolder::~WaitingTaskWithArenaHolder ( )

Definition at line 25 of file WaitingTaskWithArenaHolder.cc.

References doneWaiting(), and m_task.

25  {
26  if (m_task) {
27  doneWaiting(std::exception_ptr{});
28  }
29  }
void doneWaiting(std::exception_ptr iExcept)
edm::WaitingTaskWithArenaHolder::WaitingTaskWithArenaHolder ( WaitingTaskWithArenaHolder const &  iHolder)

Definition at line 31 of file WaitingTaskWithArenaHolder.cc.

References m_task.

32  : m_task(iHolder.m_task), m_arena(iHolder.m_arena) {
33  m_task->increment_ref_count();
34  }
std::shared_ptr< tbb::task_arena > m_arena
edm::WaitingTaskWithArenaHolder::WaitingTaskWithArenaHolder ( WaitingTaskWithArenaHolder &&  iOther)

Definition at line 36 of file WaitingTaskWithArenaHolder.cc.

37  : m_task(iOther.m_task), m_arena(std::move(iOther.m_arena)) {
38  iOther.m_task = nullptr;
39  }
std::shared_ptr< tbb::task_arena > m_arena
def move(src, dest)
Definition: eostools.py:511

Member Function Documentation

void edm::WaitingTaskWithArenaHolder::doneWaiting ( std::exception_ptr  iExcept)

Definition at line 59 of file WaitingTaskWithArenaHolder.cc.

References edm::WaitingTask::dependentTaskFailed(), m_arena, m_task, and TrackValidation_cff::task.

Referenced by edm::Worker::runAcquireAfterAsyncPrefetch(), and ~WaitingTaskWithArenaHolder().

59  {
60  if (iExcept) {
61  m_task->dependentTaskFailed(iExcept);
62  }
63  //enqueue can run the task before we finish
64  // doneWaiting and some other thread might
65  // try to reuse this object. Resetting
66  // before enqueue avoids problems
67  auto task = m_task;
68  m_task = nullptr;
69  if (0 == task->decrement_ref_count()) {
70  // The enqueue call will cause a worker thread to be created in
71  // the arena if there is not one already.
72  m_arena->enqueue([task = task]() { tbb::task::spawn(*task); });
73  }
74  }
void dependentTaskFailed(std::exception_ptr iPtr)
Called if waited for task failed.
Definition: WaitingTask.h:59
std::shared_ptr< tbb::task_arena > m_arena
WaitingTaskHolder edm::WaitingTaskWithArenaHolder::makeWaitingTaskHolderAndRelease ( )

Definition at line 88 of file WaitingTaskWithArenaHolder.cc.

References m_task.

88  {
89  WaitingTaskHolder holder(m_task);
90  m_task->decrement_ref_count();
91  m_task = nullptr;
92  return holder;
93  }
WaitingTaskWithArenaHolder & edm::WaitingTaskWithArenaHolder::operator= ( const WaitingTaskWithArenaHolder iRHS)

Definition at line 41 of file WaitingTaskWithArenaHolder.cc.

References m_arena, m_task, std::swap(), and tmp.

41  {
43  std::swap(m_task, tmp.m_task);
44  std::swap(m_arena, tmp.m_arena);
45  return *this;
46  }
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
std::shared_ptr< tbb::task_arena > m_arena
WaitingTaskWithArenaHolder & edm::WaitingTaskWithArenaHolder::operator= ( WaitingTaskWithArenaHolder &&  iRHS)

Definition at line 48 of file WaitingTaskWithArenaHolder.cc.

References m_arena, m_task, eostools::move(), std::swap(), and tmp.

48  {
50  std::swap(m_task, tmp.m_task);
51  std::swap(m_arena, tmp.m_arena);
52  return *this;
53  }
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
std::shared_ptr< tbb::task_arena > m_arena
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

std::shared_ptr<tbb::task_arena> edm::WaitingTaskWithArenaHolder::m_arena
private

Definition at line 73 of file WaitingTaskWithArenaHolder.h.

Referenced by doneWaiting(), and operator=().

WaitingTask* edm::WaitingTaskWithArenaHolder::m_task
private