LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
art::SharedException Class Reference

#include "SharedException.h"

Public Member Functions

void store (std::exception_ptr ex_ptr)
 
void store_current ()
 
template<typename T , typename... Args>
void store (Args &&...args)
 
void throw_if_stored_exception ()
 

Private Attributes

std::thread::id const ownerThread_ {std::this_thread::get_id()}
 
std::atomic< bool > cachedExceptionStored_ {false}
 
std::exception_ptr cachedException_ {}
 

Detailed Description

Definition at line 18 of file SharedException.h.

Member Function Documentation

void art::SharedException::store ( std::exception_ptr  ex_ptr)
inline

Definition at line 21 of file SharedException.h.

References cachedException_, and cachedExceptionStored_.

Referenced by art::EventProcessor::finishEventAsync(), art::EventProcessor::processEventAsync(), store(), and store_current().

22  {
23  bool expected = false;
24  if (cachedExceptionStored_.compare_exchange_strong(expected, true)) {
25  // Put the exception where the main thread can get at it.
26  cachedException_ = std::move(ex_ptr);
27  }
28  }
std::atomic< bool > cachedExceptionStored_
std::exception_ptr cachedException_
template<typename T , typename... Args>
void art::SharedException::store ( Args &&...  args)
inline

Definition at line 38 of file SharedException.h.

References store().

39  {
40  store(std::make_exception_ptr(T{std::forward<Args>(args)...}));
41  }
void store(std::exception_ptr ex_ptr)
void art::SharedException::store_current ( )
inline

Definition at line 31 of file SharedException.h.

References store().

Referenced by art::EventProcessor::finishEventAsync(), art::EventProcessor::processAllEventsAsync(), and art::EventProcessor::processEventAsync().

32  {
33  store(std::current_exception());
34  }
void store(std::exception_ptr ex_ptr)
void art::SharedException::throw_if_stored_exception ( )
inline

Definition at line 44 of file SharedException.h.

References cachedException_, cachedExceptionStored_, and ownerThread_.

Referenced by art::EventProcessor::process().

45  {
46  assert(std::this_thread::get_id() == ownerThread_);
47  if (cachedExceptionStored_.load()) {
48  std::rethrow_exception(cachedException_);
49  }
50  }
std::thread::id const ownerThread_
std::atomic< bool > cachedExceptionStored_
std::exception_ptr cachedException_

Member Data Documentation

std::exception_ptr art::SharedException::cachedException_ {}
private

Definition at line 55 of file SharedException.h.

Referenced by store(), and throw_if_stored_exception().

std::atomic<bool> art::SharedException::cachedExceptionStored_ {false}
private

Definition at line 54 of file SharedException.h.

Referenced by store(), and throw_if_stored_exception().

std::thread::id const art::SharedException::ownerThread_ {std::this_thread::get_id()}
private

Definition at line 53 of file SharedException.h.

Referenced by throw_if_stored_exception().


The documentation for this class was generated from the following file: