If exception is disabled, \p %throw_exception() prints an exception message to
standard output and call \p abort().
- You may supply your own \p %cds::throw_exception() function;
+ You can supply your own \p %cds::throw_exception() function;
for that you should specify \p -DCDS_USER_DEFINED_THROW_EXCEPTION
- in compiler command line.
+ in compiler command line.
@note \p %throw_exception() never returns. If the user-defined \p %throw_exception() returns,
the behavior is undefined.
#include <cds/details/allocator.h>
#include <cds/intrusive/vyukov_mpmc_cycle_queue.h>
+#include <cds/details/throw_exception.h>
namespace cds { namespace memory {
}
// The pool is empty
- throw std::bad_alloc();
+ CDS_THROW_EXCEPTION( std::bad_alloc() );
}
ok:
#include <memory>
#include <cds/details/is_aligned.h>
#include <cds/algo/int_algo.h>
+#include <cds/details/throw_exception.h>
namespace cds {
/// OS specific wrappers
assert( cds::beans::is_power2( nAlign ));
pointer p = reinterpret_cast<T *>( cds::OS::aligned_malloc( sizeof(T) * nCount, nAlign ));
if ( !p )
- throw std::bad_alloc();
+ CDS_THROW_EXCEPTION( std::bad_alloc() );
assert( cds::details::is_aligned( p, nAlign ));
return p;
}
#include <stdio.h>
#include <pthread.h>
#include <cds/threading/details/_common.h>
+#include <cds/details/throw_exception.h>
//@cond
namespace cds { namespace threading {
static void init()
{
pthread_error_code nErr;
- if ( (nErr = pthread_key_create( &m_key, key_destructor )) != 0 )
- throw pthread_exception( nErr, "pthread_key_create" );
+ if ( ( nErr = pthread_key_create( &m_key, key_destructor ) ) != 0 )
+ CDS_THROW_EXCEPTION( pthread_exception( nErr, "pthread_key_create" ));
}
static void fini()
{
pthread_error_code nErr;
- if ( (nErr = pthread_key_delete( m_key )) != 0 )
- throw pthread_exception( nErr, "pthread_key_delete" );
+ if ( ( nErr = pthread_key_delete( m_key ) ) != 0 )
+ CDS_THROW_EXCEPTION( pthread_exception( nErr, "pthread_key_delete" ));
}
static ThreadData * get()
{
pthread_error_code nErr;
ThreadData * pData = new ThreadData;
- if ( ( nErr = pthread_setspecific( m_key, pData )) != 0 )
- throw pthread_exception( nErr, "pthread_setspecific" );
+ if ( ( nErr = pthread_setspecific( m_key, pData ) ) != 0 )
+ CDS_THROW_EXCEPTION( pthread_exception( nErr, "pthread_setspecific" ));
}
static void free()
{
pData->init();
}
else
- throw pthread_exception( -1, "cds::threading::pthread::Manager::attachThread" );
+ CDS_THROW_EXCEPTION( pthread_exception( -1, "cds::threading::pthread::Manager::attachThread" ));
}
/// This method must be called in end of thread execution
assert( pData );
if ( pData ) {
- if ( pData->fini())
+ if ( pData->fini() )
_threadData( do_detachThread );
}
else
- throw pthread_exception( -1, "cds::threading::pthread::Manager::detachThread" );
+ CDS_THROW_EXCEPTION( pthread_exception( -1, "cds::threading::pthread::Manager::detachThread" ));
}
/// Returns ThreadData pointer for the current thread
#include <system_error>
#include <stdio.h>
#include <cds/threading/details/_common.h>
+#include <cds/details/throw_exception.h>
//@cond
namespace cds { namespace threading {
static void init()
{
if ( m_key == TLS_OUT_OF_INDEXES ) {
- if ( (m_key = ::TlsAlloc()) == TLS_OUT_OF_INDEXES )
- throw api_exception( ::GetLastError(), "TlsAlloc" );
+ if ( ( m_key = ::TlsAlloc() ) == TLS_OUT_OF_INDEXES )
+ CDS_THROW_EXCEPTION( api_exception( ::GetLastError(), "TlsAlloc" ));
}
}
{
if ( m_key != TLS_OUT_OF_INDEXES ) {
if ( ::TlsFree( m_key ) == 0 )
- throw api_exception( ::GetLastError(), "TlsFree" );
+ CDS_THROW_EXCEPTION( api_exception( ::GetLastError(), "TlsFree" ));
m_key = TLS_OUT_OF_INDEXES;
}
}
{
api_error_code nErr;
void * pData = ::TlsGetValue( m_key );
- if ( pData == nullptr && (nErr = ::GetLastError()) != ERROR_SUCCESS )
- throw api_exception( nErr, "TlsGetValue" );
+ if ( pData == nullptr && ( nErr = ::GetLastError() ) != ERROR_SUCCESS )
+ CDS_THROW_EXCEPTION( api_exception( nErr, "TlsGetValue" ));
return reinterpret_cast<ThreadData *>( pData );
}
{
ThreadData * pData = new ThreadData;
if ( !::TlsSetValue( m_key, pData ))
- throw api_exception( ::GetLastError(), "TlsSetValue" );
+ CDS_THROW_EXCEPTION( api_exception( ::GetLastError(), "TlsSetValue" ));
}
static void free()
{
if ( pData )
pData->init();
else
- throw api_exception( api_error_code(-1), "cds::threading::wintls::Manager::attachThread" );
+ CDS_THROW_EXCEPTION( api_exception( api_error_code(-1), "cds::threading::wintls::Manager::attachThread" ));
}
/// This method must be called in end of thread execution
_threadData( do_detachThread );
}
else
- throw api_exception( api_error_code(-1), "cds::threading::winapi::Manager::detachThread" );
+ CDS_THROW_EXCEPTION( api_exception( api_error_code(-1), "cds::threading::winapi::Manager::detachThread" ));
}
/// Returns ThreadData pointer for the current thread
#define CDSLIB_URCU_DETAILS_CHECK_DEADLOCK_H
#include <cds/urcu/options.h>
+#include <cds/details/throw_exception.h>
//@cond
namespace cds { namespace urcu { namespace details {
{
assert( !RCU::is_locked());
if ( RCU::is_locked())
- throw cds::urcu::rcu_deadlock();
+ CDS_THROW_EXCEPTION( cds::urcu::rcu_deadlock());
}
};
External API of gc::DHP class is changed: now only initial count
of hazard pointers can be specified in the constructor. Like new gc::HP,
the new gc::DHP supports an external allocator.
+ - Changed: exception handling. Now, exceptions raise by invoking new
+ cds::throw_exception() function. If you compile your code with exception disabled,
+ the function prints an exception message to stdout and calls abort()
+ instead of throwing. You can provide your own cds::throw_exception() function
+ and compile libcds with -DCDS_USER_DEFINED_THROW_EXCEPTION.
- Fixed a bug in BronsonAVLTreeMap::extract_min()/extract_max()/clear().
- Added more flat-combining queue tests, thanks to Marsel Galimullin.
- Changed cmake scripts to support MacOS and ARMv7/ARMv8 (64 bit),