/// 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
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
/// 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;
}
};
/// 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
static GarbageCollector& instance()
{
if ( !m_pHZPManager )
- throw HZPManagerEmpty();
+ throw not_initialized();
return *m_pHZPManager;
}
/// 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