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 &&iOther)
 
 WaitingTaskWithArenaHolder (WaitingTaskWithArenaHolder const &iHolder)
 
 ~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 31 of file WaitingTaskWithArenaHolder.h.

Constructor & Destructor Documentation

◆ WaitingTaskWithArenaHolder() [1/4]

edm::WaitingTaskWithArenaHolder::WaitingTaskWithArenaHolder ( )

Definition at line 16 of file WaitingTaskWithArenaHolder.cc.

16 : m_task(nullptr) {}

◆ WaitingTaskWithArenaHolder() [2/4]

edm::WaitingTaskWithArenaHolder::WaitingTaskWithArenaHolder ( WaitingTask iTask)
explicit

Definition at line 21 of file WaitingTaskWithArenaHolder.cc.

22  : m_task(iTask), m_arena(std::make_shared<tbb::task_arena>(tbb::task_arena::attach())) {
23  m_task->increment_ref_count();
24  }

References m_task.

◆ ~WaitingTaskWithArenaHolder()

edm::WaitingTaskWithArenaHolder::~WaitingTaskWithArenaHolder ( )

Definition at line 26 of file WaitingTaskWithArenaHolder.cc.

26  {
27  if (m_task) {
28  doneWaiting(std::exception_ptr{});
29  }
30  }

References doneWaiting(), and m_task.

◆ WaitingTaskWithArenaHolder() [3/4]

edm::WaitingTaskWithArenaHolder::WaitingTaskWithArenaHolder ( WaitingTaskWithArenaHolder const &  iHolder)

Definition at line 32 of file WaitingTaskWithArenaHolder.cc.

33  : m_task(iHolder.m_task), m_arena(iHolder.m_arena) {
34  if (LIKELY(m_task != nullptr)) {
35  m_task->increment_ref_count();
36  }
37  }

References LIKELY, and m_task.

◆ WaitingTaskWithArenaHolder() [4/4]

edm::WaitingTaskWithArenaHolder::WaitingTaskWithArenaHolder ( WaitingTaskWithArenaHolder &&  iOther)

Definition at line 39 of file WaitingTaskWithArenaHolder.cc.

40  : m_task(iOther.m_task), m_arena(std::move(iOther.m_arena)) {
41  iOther.m_task = nullptr;
42  }

Member Function Documentation

◆ doneWaiting()

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

Definition at line 62 of file WaitingTaskWithArenaHolder.cc.

62  {
63  if (iExcept) {
64  m_task->dependentTaskFailed(iExcept);
65  }
66  //enqueue can run the task before we finish
67  // doneWaiting and some other thread might
68  // try to reuse this object. Resetting
69  // before enqueue avoids problems
70  auto task = m_task;
71  m_task = nullptr;
72  if (0 == task->decrement_ref_count()) {
73  // The enqueue call will cause a worker thread to be created in
74  // the arena if there is not one already.
75  m_arena->enqueue([task = task]() { tbb::task::spawn(*task); });
76  }
77  }

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

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

◆ makeWaitingTaskHolderAndRelease()

WaitingTaskHolder edm::WaitingTaskWithArenaHolder::makeWaitingTaskHolderAndRelease ( )

Definition at line 91 of file WaitingTaskWithArenaHolder.cc.

91  {
92  WaitingTaskHolder holder(m_task);
93  m_task->decrement_ref_count();
94  m_task = nullptr;
95  return holder;
96  }

References m_task.

◆ operator=() [1/2]

WaitingTaskWithArenaHolder & edm::WaitingTaskWithArenaHolder::operator= ( const WaitingTaskWithArenaHolder iRHS)

Definition at line 44 of file WaitingTaskWithArenaHolder.cc.

44  {
46  std::swap(m_task, tmp.m_task);
47  std::swap(m_arena, tmp.m_arena);
48  return *this;
49  }

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

◆ operator=() [2/2]

WaitingTaskWithArenaHolder & edm::WaitingTaskWithArenaHolder::operator= ( WaitingTaskWithArenaHolder &&  iRHS)

Definition at line 51 of file WaitingTaskWithArenaHolder.cc.

51  {
53  std::swap(m_task, tmp.m_task);
54  std::swap(m_arena, tmp.m_arena);
55  return *this;
56  }

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

Member Data Documentation

◆ m_arena

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

Definition at line 72 of file WaitingTaskWithArenaHolder.h.

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

◆ m_task

WaitingTask* edm::WaitingTaskWithArenaHolder::m_task
private
edm::WaitingTaskWithArenaHolder::WaitingTaskWithArenaHolder
WaitingTaskWithArenaHolder()
Definition: WaitingTaskWithArenaHolder.cc:16
edm::WaitingTaskWithArenaHolder::m_task
WaitingTask * m_task
Definition: WaitingTaskWithArenaHolder.h:71
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
edm::WaitingTaskWithArenaHolder::m_arena
std::shared_ptr< tbb::task_arena > m_arena
Definition: WaitingTaskWithArenaHolder.h:72
std::swap
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
Definition: DataFrameContainer.h:209
TrackValidation_cff.task
task
Definition: TrackValidation_cff.py:252
WaitingTaskHolder
edm::WaitingTask::dependentTaskFailed
void dependentTaskFailed(std::exception_ptr iPtr)
Called if waited for task failed.
Definition: WaitingTask.h:59
eostools.move
def move(src, dest)
Definition: eostools.py:511
LIKELY
#define LIKELY(x)
Definition: Likely.h:20
edm::WaitingTaskWithArenaHolder::doneWaiting
void doneWaiting(std::exception_ptr iExcept)
Definition: WaitingTaskWithArenaHolder.cc:62