cppu/source/threadpool/current.cxx | 49 ++++--------------------------------- 1 file changed, 6 insertions(+), 43 deletions(-)
New commits: commit ef6a57ed4e8984bed06e2911b07436498710d80d Author: Mike Kaganski <[email protected]> AuthorDate: Fri Jan 29 14:58:02 2021 +0100 Commit: Mike Kaganski <[email protected]> CommitDate: Sat Jan 30 22:14:36 2021 +0100 Don't use global mutex here for static initialization Change-Id: I3fa0cd7e31a8c89b5fb1eba7b36636e02a785df8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110140 Tested-by: Jenkins Reviewed-by: Mike Kaganski <[email protected]> diff --git a/cppu/source/threadpool/current.cxx b/cppu/source/threadpool/current.cxx index 7dbfc9050488..6acad514cac7 100644 --- a/cppu/source/threadpool/current.cxx +++ b/cppu/source/threadpool/current.cxx @@ -81,47 +81,6 @@ static typelib_InterfaceTypeDescription * get_type_XCurrentContext() return s_type_XCurrentContext; } -namespace { - -class ThreadKey -{ - bool _bInit; - oslThreadKey _hThreadKey; - oslThreadKeyCallbackFunction _pCallback; - -public: - oslThreadKey getThreadKey() - { - if (! _bInit) - { - MutexGuard aGuard( Mutex::getGlobalMutex() ); - if (! _bInit) - { - _hThreadKey = ::osl_createThreadKey( _pCallback ); - _bInit = true; - } - } - return _hThreadKey; - } - - explicit ThreadKey( oslThreadKeyCallbackFunction pCallback ) - : _bInit(false) - , _hThreadKey(nullptr) - , _pCallback(pCallback) - { - } - - ~ThreadKey() - { - if (_bInit) - { - ::osl_destroyThreadKey( _hThreadKey ); - } - } -}; - -} - extern "C" { static void delete_IdContainer( void * p ) @@ -149,8 +108,12 @@ static void delete_IdContainer( void * p ) IdContainer * getIdContainer() { - static ThreadKey s_key( delete_IdContainer ); - oslThreadKey aKey = s_key.getThreadKey(); + struct ThreadKey + { + oslThreadKey _hThreadKey; + ~ThreadKey() { osl_destroyThreadKey(_hThreadKey); } + } static const s_key{ osl_createThreadKey(delete_IdContainer) }; + oslThreadKey aKey = s_key._hThreadKey; IdContainer * pId = static_cast< IdContainer * >( ::osl_getThreadKeyData( aKey ) ); if (! pId) _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
