#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