/*
This file is a part of libcds - Concurrent Data Structures library
- (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016
+ (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2017
Source code repo: http://github.com/khizmax/libcds/
Download: http://sourceforge.net/projects/libcds/files/
#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()
{
- return reinterpret_cast<ThreadData *>( pthread_getspecific( m_key ) );
+ return reinterpret_cast<ThreadData *>( pthread_getspecific( m_key ));
}
static void alloc()
pthread_error_code nErr;
ThreadData * pData = new ThreadData;
if ( ( nErr = pthread_setspecific( m_key, pData )) != 0 )
- throw pthread_exception( nErr, "pthread_setspecific" );
+ 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
return _threadData( do_getData );
}
- /// Get gc::HP thread GC implementation for current thread
- /**
- The object returned may be uninitialized if you did not call attachThread in the beginning of thread execution
- or if you did not use gc::HP.
- To initialize gc::HP GC you must constuct cds::gc::HP object in the beginning of your application
- */
- static gc::HP::thread_gc_impl& getHZPGC()
- {
- return *(_threadData( do_getData )->m_hpManager);
- }
-
- /// Get gc::DHP thread GC implementation for current thread
- /**
- The object returned may be uninitialized if you did not call attachThread in the beginning of thread execution
- or if you did not use gc::DHP.
- To initialize gc::DHP GC you must constuct cds::gc::DHP object in the beginning of your application
- */
- static gc::DHP::thread_gc_impl& getDHPGC()
- {
- return *(_threadData( do_getData )->m_dhpManager);
- }
-
//@cond
static size_t fake_current_processor()
{