Public Member Functions | Private Attributes | List of all members
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< boolcachedExceptionStored_ {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.

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  }
const char expected[]
Definition: Exception_t.cc:22
std::atomic< bool > cachedExceptionStored_
def move(depos, offset)
Definition: depos.py:107
std::exception_ptr cachedException_
template<typename T , typename... Args>
void art::SharedException::store ( Args &&...  args)
inline

Definition at line 38 of file SharedException.h.

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

Definition at line 31 of file SharedException.h.

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.

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.

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

Definition at line 54 of file SharedException.h.

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

Definition at line 53 of file SharedException.h.


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