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) {
16  }
edm::WaitingTaskWithArenaHolder::WaitingTaskWithArenaHolder ( WaitingTask iTask)
explicit

Definition at line 21 of file WaitingTaskWithArenaHolder.cc.

References m_task.

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

Definition at line 28 of file WaitingTaskWithArenaHolder.cc.

References doneWaiting(), and m_task.

28  {
29  if (m_task) {
30  doneWaiting(std::exception_ptr{});
31  }
32  }
void doneWaiting(std::exception_ptr iExcept)
edm::WaitingTaskWithArenaHolder::WaitingTaskWithArenaHolder ( WaitingTaskWithArenaHolder const &  iHolder)

Definition at line 34 of file WaitingTaskWithArenaHolder.cc.

References m_task.

34  :
35  m_task(iHolder.m_task),
36  m_arena(iHolder.m_arena) {
37 
38  m_task->increment_ref_count();
39  }
std::shared_ptr< tbb::task_arena > m_arena
edm::WaitingTaskWithArenaHolder::WaitingTaskWithArenaHolder ( WaitingTaskWithArenaHolder &&  iOther)

Definition at line 41 of file WaitingTaskWithArenaHolder.cc.

41  :
42  m_task(iOther.m_task),
43  m_arena(std::move(iOther.m_arena)) {
44 
45  iOther.m_task = nullptr;
46  }
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 66 of file WaitingTaskWithArenaHolder.cc.

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

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

66  {
67  if (iExcept) {
68  m_task->dependentTaskFailed(iExcept);
69  }
70  if (0 == m_task->decrement_ref_count()) {
71  // The enqueue call will cause a worker thread to be created in
72  // the arena if there is not one already.
73  m_arena->enqueue( [m_task = m_task](){ tbb::task::spawn(*m_task); });
74  }
75  m_task = nullptr;
76  }
void dependentTaskFailed(std::exception_ptr iPtr)
Called if waited for task failed.
Definition: WaitingTask.h:64
std::shared_ptr< tbb::task_arena > m_arena
WaitingTaskHolder edm::WaitingTaskWithArenaHolder::makeWaitingTaskHolderAndRelease ( )

Definition at line 90 of file WaitingTaskWithArenaHolder.cc.

References m_task.

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

Definition at line 48 of file WaitingTaskWithArenaHolder.cc.

References m_arena, m_task, 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
WaitingTaskWithArenaHolder & edm::WaitingTaskWithArenaHolder::operator= ( WaitingTaskWithArenaHolder &&  iRHS)

Definition at line 55 of file WaitingTaskWithArenaHolder.cc.

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

55  {
57  std::swap(m_task, tmp.m_task);
58  std::swap(m_arena, tmp.m_arena);
59  return *this;
60  }
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 75 of file WaitingTaskWithArenaHolder.h.

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

WaitingTask* edm::WaitingTaskWithArenaHolder::m_task
private