remove deprecated tbb_exception in favor of std_exception
							parent
							
								
									1483df7aa0
								
							
						
					
					
						commit
						af5d22248b
					
				|  | @ -11,7 +11,7 @@ | |||
| 
 | ||||
| /**
 | ||||
|  * @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 | ||||
|  * @date     Aug 21, 2010 | ||||
|  * @addtogroup base | ||||
|  | @ -25,34 +25,28 @@ | |||
| #include <gtsam/dllexport.h> | ||||
| #include <string> | ||||
| #include <typeinfo> | ||||
| #include <exception> | ||||
| 
 | ||||
| #ifdef GTSAM_USE_TBB | ||||
| #include <tbb/tbb_allocator.h> | ||||
| #include <tbb/tbb_exception.h> | ||||
| #include <tbb/scalable_allocator.h> | ||||
| #include <iostream> | ||||
| #endif | ||||
| 
 | ||||
| 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> | ||||
| class ThreadsafeException: | ||||
| #ifdef GTSAM_USE_TBB | ||||
|     public tbb::tbb_exception | ||||
| #else | ||||
| public std::exception | ||||
| #endif | ||||
| { | ||||
| #ifdef GTSAM_USE_TBB | ||||
| private: | ||||
|   typedef tbb::tbb_exception Base; | ||||
|   typedef std::exception Base; | ||||
| #ifdef GTSAM_USE_TBB | ||||
| protected: | ||||
|   typedef std::basic_string<char, std::char_traits<char>, | ||||
|       tbb::tbb_allocator<char> > String; | ||||
| #else | ||||
| private: | ||||
|   typedef std::exception Base; | ||||
| protected: | ||||
|   typedef std::string String; | ||||
| #endif | ||||
|  | @ -82,36 +76,6 @@ protected: | |||
|   } | ||||
| 
 | ||||
| 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 () { | ||||
|     return description_ ? description_->c_str() : ""; | ||||
|   } | ||||
|  |  | |||
|  | @ -27,8 +27,9 @@ | |||
| #include <cstddef> | ||||
| #include <cstdint> | ||||
| 
 | ||||
| #include <exception> | ||||
| 
 | ||||
| #ifdef GTSAM_USE_TBB | ||||
| #include <tbb/tbb_exception.h> | ||||
| #include <tbb/scalable_allocator.h> | ||||
| #endif | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue