remove deprecated tbb_exception in favor of std_exception

release/4.3a0
acxz 2020-01-11 16:37:13 -05:00
parent 1483df7aa0
commit af5d22248b
2 changed files with 7 additions and 42 deletions

View File

@ -11,7 +11,7 @@
/** /**
* @file ThreadSafeException.h * @file ThreadSafeException.h
* @brief Base exception type that uses tbb_exception if GTSAM is compiled with TBB * @brief Base exception type that uses tbb_allocator if GTSAM is compiled with TBB
* @author Richard Roberts * @author Richard Roberts
* @date Aug 21, 2010 * @date Aug 21, 2010
* @addtogroup base * @addtogroup base
@ -25,34 +25,28 @@
#include <gtsam/dllexport.h> #include <gtsam/dllexport.h>
#include <string> #include <string>
#include <typeinfo> #include <typeinfo>
#include <exception>
#ifdef GTSAM_USE_TBB #ifdef GTSAM_USE_TBB
#include <tbb/tbb_allocator.h> #include <tbb/tbb_allocator.h>
#include <tbb/tbb_exception.h>
#include <tbb/scalable_allocator.h> #include <tbb/scalable_allocator.h>
#include <iostream> #include <iostream>
#endif #endif
namespace gtsam { namespace gtsam {
/// Base exception type that uses tbb_exception if GTSAM is compiled with TBB. /// Base exception type that uses tbb_allocator if GTSAM is compiled with TBB.
template<class DERIVED> template<class DERIVED>
class ThreadsafeException: class ThreadsafeException:
#ifdef GTSAM_USE_TBB
public tbb::tbb_exception
#else
public std::exception public std::exception
#endif
{ {
#ifdef GTSAM_USE_TBB
private: private:
typedef tbb::tbb_exception Base; typedef std::exception Base;
#ifdef GTSAM_USE_TBB
protected: protected:
typedef std::basic_string<char, std::char_traits<char>, typedef std::basic_string<char, std::char_traits<char>,
tbb::tbb_allocator<char> > String; tbb::tbb_allocator<char> > String;
#else #else
private:
typedef std::exception Base;
protected: protected:
typedef std::string String; typedef std::string String;
#endif #endif
@ -82,36 +76,6 @@ protected:
} }
public: public:
// Implement functions for tbb_exception
#ifdef GTSAM_USE_TBB
virtual tbb::tbb_exception* move() throw () {
void* cloneMemory = scalable_malloc(sizeof(DERIVED));
if (!cloneMemory) {
std::cerr << "Failed allocating memory to copy thrown exception, exiting now." << std::endl;
exit(-1);
}
DERIVED* clone = ::new(cloneMemory) DERIVED(static_cast<DERIVED&>(*this));
clone->dynamic_ = true;
return clone;
}
virtual void destroy() throw () {
if (dynamic_) {
DERIVED* derivedPtr = static_cast<DERIVED*>(this);
derivedPtr->~DERIVED();
scalable_free(derivedPtr);
}
}
virtual void throw_self() {
throw *static_cast<DERIVED*>(this);
}
virtual const char* name() const throw () {
return typeid(DERIVED).name();
}
#endif
virtual const char* what() const throw () { virtual const char* what() const throw () {
return description_ ? description_->c_str() : ""; return description_ ? description_->c_str() : "";
} }

View File

@ -27,8 +27,9 @@
#include <cstddef> #include <cstddef>
#include <cstdint> #include <cstdint>
#include <exception>
#ifdef GTSAM_USE_TBB #ifdef GTSAM_USE_TBB
#include <tbb/tbb_exception.h>
#include <tbb/scalable_allocator.h> #include <tbb/scalable_allocator.h>
#endif #endif