CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | Friends
edm::WaitingTask Class Reference

#include <WaitingTask.h>

Inheritance diagram for edm::WaitingTask:
edm::TaskBase edm::FinalWaitingTask edm::FunctorWaitingTask< F > edm::Worker::AcquireTask< T, DUMMY > edm::Worker::AcquireTask< OccurrenceTraits< EventPrincipal, BranchActionStreamBegin >, DUMMY > edm::Worker::HandleExternalWorkExceptionTask edm::Worker::RunModuleTask< T >

Public Member Functions

std::exception_ptr exceptionPtr () const noexcept
 Returns exception thrown by dependent task. More...
 
 WaitingTask () noexcept
 Constructor. More...
 
 ~WaitingTask () noexcept override
 
- Public Member Functions inherited from edm::TaskBase
unsigned int decrement_ref_count () noexcept
 
virtual void execute ()=0
 
void increment_ref_count () noexcept
 
 TaskBase () noexcept
 Constructor. More...
 
virtual ~TaskBase () noexcept=default
 

Protected Member Functions

std::exception_ptr const & uncheckedExceptionPtr () const noexcept
 

Private Types

enum  State : unsigned char { State::kUnset = 0, State::kSetting = 1, State::kSet = 2 }
 

Private Member Functions

void dependentTaskFailed (std::exception_ptr iPtr) noexcept
 Called if waited for task failed. More...
 

Private Attributes

std::exception_ptr m_ptr
 
std::atomic< unsigned char > m_ptrSet = static_cast<unsigned char>(State::kUnset)
 

Friends

class WaitingTaskHolder
 
class WaitingTaskList
 
class WaitingTaskWithArenaHolder
 

Detailed Description

Definition at line 36 of file WaitingTask.h.

Member Enumeration Documentation

◆ State

enum edm::WaitingTask::State : unsigned char
strongprivate
Enumerator
kUnset 
kSetting 
kSet 

Definition at line 62 of file WaitingTask.h.

62 : unsigned char { kUnset = 0, kSetting = 1, kSet = 2 };
const char * kSet
constexpr unsigned int kUnset

Constructor & Destructor Documentation

◆ WaitingTask()

edm::WaitingTask::WaitingTask ( )
inlinenoexcept

Constructor.

Definition at line 43 of file WaitingTask.h.

43 : m_ptr{} {}
std::exception_ptr m_ptr
Definition: WaitingTask.h:76

◆ ~WaitingTask()

edm::WaitingTask::~WaitingTask ( )
inlineoverridenoexcept

Definition at line 44 of file WaitingTask.h.

44 {}

Member Function Documentation

◆ dependentTaskFailed()

void edm::WaitingTask::dependentTaskFailed ( std::exception_ptr  iPtr)
inlineprivatenoexcept

Called if waited for task failed.

Allows transfer of the exception caused by the dependent task to be moved to another thread. This method should only be called by WaitingTaskList

Definition at line 68 of file WaitingTask.h.

References kSet, kSetting, kUnset, m_ptr, and m_ptrSet.

Referenced by edm::WaitingTaskList::add(), edm::WaitingTaskWithArenaHolder::doneWaiting(), edm::WaitingTaskHolder::doneWaiting(), edm::WaitingTaskHolder::presetTaskAsFailed(), and edm::WaitingTaskList::presetTaskAsFailed().

68  {
69  unsigned char isSet = static_cast<unsigned char>(State::kUnset);
70  if (iPtr and m_ptrSet.compare_exchange_strong(isSet, static_cast<unsigned char>(State::kSetting))) {
71  m_ptr = iPtr;
72  m_ptrSet = static_cast<unsigned char>(State::kSet);
73  }
74  }
std::atomic< unsigned char > m_ptrSet
Definition: WaitingTask.h:77
std::exception_ptr m_ptr
Definition: WaitingTask.h:76

◆ exceptionPtr()

std::exception_ptr edm::WaitingTask::exceptionPtr ( ) const
inlinenoexcept

Returns exception thrown by dependent task.

If the value evalutes to true then the dependent task failed.

Definition at line 51 of file WaitingTask.h.

References kSet, m_ptr, and m_ptrSet.

Referenced by edm::Worker::AcquireTask< OccurrenceTraits< EventPrincipal, BranchActionStreamBegin >, DUMMY >::execute(), edm::Worker::HandleExternalWorkExceptionTask::execute(), edm::WaitingTaskHolder::taskHasFailed(), edm::WaitingTaskWithArenaHolder::taskHasFailed(), edm::FinalWaitingTask::wait(), and edm::FinalWaitingTask::waitNoThrow().

51  {
52  if (m_ptrSet == static_cast<unsigned char>(State::kSet)) {
53  return m_ptr;
54  }
55  return std::exception_ptr{};
56  }
std::atomic< unsigned char > m_ptrSet
Definition: WaitingTask.h:77
std::exception_ptr m_ptr
Definition: WaitingTask.h:76

◆ uncheckedExceptionPtr()

std::exception_ptr const& edm::WaitingTask::uncheckedExceptionPtr ( ) const
inlineprotectednoexcept

Definition at line 59 of file WaitingTask.h.

References m_ptr.

59 { return m_ptr; }
std::exception_ptr m_ptr
Definition: WaitingTask.h:76

Friends And Related Function Documentation

◆ WaitingTaskHolder

friend class WaitingTaskHolder
friend

Definition at line 39 of file WaitingTask.h.

◆ WaitingTaskList

friend class WaitingTaskList
friend

Definition at line 38 of file WaitingTask.h.

◆ WaitingTaskWithArenaHolder

friend class WaitingTaskWithArenaHolder
friend

Definition at line 40 of file WaitingTask.h.

Member Data Documentation

◆ m_ptr

std::exception_ptr edm::WaitingTask::m_ptr
private

Definition at line 76 of file WaitingTask.h.

Referenced by dependentTaskFailed(), exceptionPtr(), and uncheckedExceptionPtr().

◆ m_ptrSet

std::atomic<unsigned char> edm::WaitingTask::m_ptrSet = static_cast<unsigned char>(State::kUnset)
private

Definition at line 77 of file WaitingTask.h.

Referenced by dependentTaskFailed(), and exceptionPtr().