diff options
Diffstat (limited to 'cppu/source/threadpool/current.cxx')
-rw-r--r-- | cppu/source/threadpool/current.cxx | 48 |
1 files changed, 21 insertions, 27 deletions
diff --git a/cppu/source/threadpool/current.cxx b/cppu/source/threadpool/current.cxx index 610d4b35e755..cc313cdf925a 100644 --- a/cppu/source/threadpool/current.cxx +++ b/cppu/source/threadpool/current.cxx @@ -106,41 +106,35 @@ class ThreadKey oslThreadKeyCallbackFunction _pCallback; public: - inline oslThreadKey getThreadKey(); - - inline ThreadKey( oslThreadKeyCallbackFunction pCallback ); - inline ~ThreadKey(); -}; - -inline ThreadKey::ThreadKey( oslThreadKeyCallbackFunction pCallback ) - : _bInit( false ) - , _hThreadKey( 0 ) - , _pCallback( pCallback ) -{ -} + oslThreadKey getThreadKey() + { + if (! _bInit) + { + MutexGuard aGuard( Mutex::getGlobalMutex() ); + if (! _bInit) + { + _hThreadKey = ::osl_createThreadKey( _pCallback ); + _bInit = true; + } + } + return _hThreadKey; + } -inline ThreadKey::~ThreadKey() -{ - if (_bInit) + explicit ThreadKey( oslThreadKeyCallbackFunction pCallback ) + : _bInit(false) + , _hThreadKey(0) + , _pCallback(pCallback) { - ::osl_destroyThreadKey( _hThreadKey ); } -} -inline oslThreadKey ThreadKey::getThreadKey() -{ - if (! _bInit) + ~ThreadKey() { - MutexGuard aGuard( Mutex::getGlobalMutex() ); - if (! _bInit) + if (_bInit) { - _hThreadKey = ::osl_createThreadKey( _pCallback ); - _bInit = true; + ::osl_destroyThreadKey( _hThreadKey ); } } - return _hThreadKey; -} - +}; extern "C" void SAL_CALL delete_IdContainer( void * p ) { |