22 #include <gtsam/config.h> 24 #include <boost/optional/optional.hpp> 29 #include <tbb/tbb_allocator.h> 30 #include <tbb/tbb_exception.h> 31 #include <tbb/scalable_allocator.h> 38 template<
class DERIVED>
41 public tbb::tbb_exception
48 typedef tbb::tbb_exception Base;
50 typedef std::basic_string<char, std::char_traits<char>,
51 tbb::tbb_allocator<char> > String;
54 typedef std::exception Base;
56 typedef std::string String;
70 Base(other), dynamic_(false) {
75 dynamic_(false), description_(
76 String(description.begin(), description.end())) {
86 virtual tbb::tbb_exception* move()
throw () {
87 void* cloneMemory = scalable_malloc(
sizeof(DERIVED));
89 std::cerr <<
"Failed allocating memory to copy thrown exception, exiting now." << std::endl;
92 DERIVED* clone = ::new(cloneMemory) DERIVED(static_cast<DERIVED&>(*
this));
93 clone->dynamic_ =
true;
97 virtual void destroy()
throw () {
99 DERIVED* derivedPtr =
static_cast<DERIVED*
>(
this);
100 derivedPtr->~DERIVED();
101 scalable_free(derivedPtr);
105 virtual void throw_self() {
106 throw *
static_cast<DERIVED*
>(
this);
109 virtual const char* name()
const throw () {
110 return typeid(DERIVED).name();
114 virtual const char* what()
const throw () {
115 return description_ ? description_->c_str() :
"";
139 InvalidArgumentThreadsafe> {
virtual ~ThreadsafeException()
Default destructor doesn't have the throw()
Definition: ThreadsafeException.h:80
Base exception type that uses tbb_exception if GTSAM is compiled with TBB.
Definition: ThreadsafeException.h:39
ThreadsafeException()
Default constructor is protected - may only be created from derived classes.
Definition: ThreadsafeException.h:64
RuntimeErrorThreadsafe(const std::string &description)
Construct with a string describing the exception.
Definition: ThreadsafeException.h:123
OutOfRangeThreadsafe(const std::string &description)
Construct with a string describing the exception.
Definition: ThreadsafeException.h:132
ThreadsafeException(const std::string &description)
Construct with description string.
Definition: ThreadsafeException.h:74
boost::optional< String > description_
Optional description.
Definition: ThreadsafeException.h:61
Thread-safe invalid argument exception.
Definition: ThreadsafeException.h:138
Thread-safe runtime error exception.
Definition: ThreadsafeException.h:120
bool dynamic_
Whether this object was moved.
Definition: ThreadsafeException.h:60
Indicate Cholesky factorization failure.
Definition: ThreadsafeException.h:148
InvalidArgumentThreadsafe(const std::string &description)
Construct with a string describing the exception.
Definition: ThreadsafeException.h:142
ThreadsafeException(const ThreadsafeException &other)
Copy constructor is protected - may only be created from derived classes.
Definition: ThreadsafeException.h:69
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
Thread-safe out of range exception.
Definition: ThreadsafeException.h:129