From: khizmax Date: Sun, 30 Nov 2014 13:01:34 +0000 (+0300) Subject: Removed CDS_DECLARE_EXCEPTION macro X-Git-Tag: v2.0.0~28 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=79598e544ba2a25fe0877458a00223e29ae87487;p=libcds.git Removed CDS_DECLARE_EXCEPTION macro --- diff --git a/cds/details/defs.h b/cds/details/defs.h index fa8a6638..9f66891a 100644 --- a/cds/details/defs.h +++ b/cds/details/defs.h @@ -430,18 +430,6 @@ namespace cds { /// any_type is used as a placeholder for auto-calculated type (usually in \p rebind templates) struct any_type {}; - /** \def CDS_DECLARE_EXCEPTION( _class, _msg ) - Simplifying declaration of specific exception (usual within classes) - - @p _class - the class name of exception - - @p _msg - exception message (const char *) - */ -#define CDS_DECLARE_EXCEPTION( _class, _msg ) \ - struct _class: public std::exception { \ - public: \ - _class(): std::exception() {} \ - virtual const char * what( ) const throw() { return _msg; } \ - } - } // namespace cds diff --git a/cds/gc/details/dhp.h b/cds/gc/details/dhp.h index 7c918bae..3f30422d 100644 --- a/cds/gc/details/dhp.h +++ b/cds/gc/details/dhp.h @@ -671,7 +671,15 @@ namespace cds { namespace gc { public: /// Exception "No GarbageCollector object is created" - CDS_DECLARE_EXCEPTION( DHPManagerEmpty, "Global DHP GarbageCollector is NULL" ); + class not_initialized : public std::runtime_error + { + public: + //@cond + not_initialized() + : std::runtime_error( "Global DHP GarbageCollector is not initialized" ) + {} + //@endcond + }; /// Internal GC statistics struct InternalState @@ -739,12 +747,12 @@ namespace cds { namespace gc { /// Returns pointer to GarbageCollector instance /** - If DHP GC is not initialized, \p DHPManagerEmpty exception is thrown + If DHP GC is not initialized, \p not_initialized exception is thrown */ static GarbageCollector& instance() { if ( m_pManager == nullptr ) - throw DHPManagerEmpty(); + throw not_initialized(); return *m_pManager; } diff --git a/cds/gc/details/hp.h b/cds/gc/details/hp.h index 70d71da2..d33b72fb 100644 --- a/cds/gc/details/hp.h +++ b/cds/gc/details/hp.h @@ -214,10 +214,26 @@ namespace cds { }; /// No GarbageCollector object is created - CDS_DECLARE_EXCEPTION( HZPManagerEmpty, "Global Hazard Pointer GarbageCollector is NULL" ); + class not_initialized : public std::runtime_error + { + public: + //@cond + not_initialized() + : std::runtime_error( "Global Hazard Pointer GarbageCollector is not initialized" ) + {} + //@endcond + }; /// Not enough required Hazard Pointer count - CDS_DECLARE_EXCEPTION( HZPTooMany, "Not enough required Hazard Pointer count" ); + class too_many_hazard_ptr : public std::length_error + { + public: + //@cond + too_many_hazard_ptr() + : std::length_error( "Not enough required Hazard Pointer count" ) + {} + //@endcond + }; private: /// Internal GC statistics @@ -332,7 +348,7 @@ namespace cds { static GarbageCollector& instance() { if ( !m_pHZPManager ) - throw HZPManagerEmpty(); + throw not_initialized(); return *m_pHZPManager; } @@ -378,12 +394,12 @@ namespace cds { /// Checks that required hazard pointer count \p nRequiredCount is less or equal then max hazard pointer count /** - If \p nRequiredCount > getHazardPointerCount() then the exception HZPTooMany is thrown + If \p nRequiredCount > getHazardPointerCount() then the exception \p too_many_hazard_ptr is thrown */ static void checkHPCount( unsigned int nRequiredCount ) { if ( instance().getHazardPointerCount() < nRequiredCount ) - throw HZPTooMany(); + throw too_many_hazard_ptr(); } /// Get current scan strategy