Removed CDS_DECLARE_EXCEPTION macro
authorkhizmax <libcds.dev@gmail.com>
Sun, 30 Nov 2014 13:01:34 +0000 (16:01 +0300)
committerkhizmax <libcds.dev@gmail.com>
Sun, 30 Nov 2014 13:01:34 +0000 (16:01 +0300)
cds/details/defs.h
cds/gc/details/dhp.h
cds/gc/details/hp.h

index fa8a66385e0e2d2c4f5d3ccfa6a113297a481782..9f66891aae50c447763d93368ead222d781b0010 100644 (file)
@@ -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
 
 
index 7c918baeebf84760d69deebe9af6bd3d8c60e554..3f30422d35858bd08fb7806abc6bce5433888ea3 100644 (file)
@@ -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;
             }
 
index 70d71da2a2408d9518d895f0f8575f36dc91bd56..d33b72fb1d95dd887e1ec237d58603defda57abf 100644 (file)
@@ -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