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;
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 () {
139 InvalidArgumentThreadsafe> {
ThreadsafeException(const std::string &description)
Construct with description string.
Definition: ThreadsafeException.h:74
Thread-safe invalid argument exception.
Definition: ThreadsafeException.h:138
Base exception type that uses tbb_exception if GTSAM is compiled with TBB.
Definition: ThreadsafeException.h:39
InvalidArgumentThreadsafe(const std::string &description)
Construct with a string describing the exception.
Definition: ThreadsafeException.h:142
OutOfRangeThreadsafe(const std::string &description)
Construct with a string describing the exception.
Definition: ThreadsafeException.h:132
Thread-safe out of range exception.
Definition: ThreadsafeException.h:129
Indicate Cholesky factorization failure.
Definition: ThreadsafeException.h:148
bool dynamic_
Whether this object was moved.
Definition: ThreadsafeException.h:60
ThreadsafeException(const ThreadsafeException &other)
Copy constructor is protected - may only be created from derived classes.
Definition: ThreadsafeException.h:69
virtual ~ThreadsafeException()
Default destructor doesn't have the throw()
Definition: ThreadsafeException.h:80
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
boost::optional< String > description_
Optional description.
Definition: ThreadsafeException.h:61
Thread-safe runtime error exception.
Definition: ThreadsafeException.h:120
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