From 4d3e4c1cf3f117b8abd8dd67843864bb4c2e5a2f Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 18 Nov 2021 20:13:51 +0200 Subject: rtl::Static->thread-safe static in tools Change-Id: I6c45fc533ec6281d011282bf2e8d49f23e2c29e6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125494 Tested-by: Jenkins Reviewed-by: Noel Grandin --- tools/source/stream/strmunx.cxx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'tools/source') diff --git a/tools/source/stream/strmunx.cxx b/tools/source/stream/strmunx.cxx index 6743993f112e..853389266ac3 100644 --- a/tools/source/stream/strmunx.cxx +++ b/tools/source/stream/strmunx.cxx @@ -30,7 +30,6 @@ #include #include -#include using namespace osl; @@ -38,7 +37,11 @@ using namespace osl; namespace { -struct LockMutex : public rtl::Static< osl::Mutex, LockMutex > {}; +osl::Mutex& LockMutex() +{ + static osl::Mutex SINGLETON; + return SINGLETON; +} std::map gLocks; @@ -60,7 +63,7 @@ bool lockFile( const SvFileStream* pStream ) if( aStatus.getFileType() == osl::FileStatus::Directory ) return true; - osl::MutexGuard aGuard( LockMutex::get() ); + osl::MutexGuard aGuard( LockMutex() ); for( const auto& [rLockStream, rLockItem] : gLocks ) { if( aItem.isIdenticalTo( rLockItem ) ) @@ -83,7 +86,7 @@ bool lockFile( const SvFileStream* pStream ) void unlockFile( SvFileStream const * pStream ) { - osl::MutexGuard aGuard( LockMutex::get() ); + osl::MutexGuard aGuard( LockMutex() ); gLocks.erase(pStream); } -- cgit