diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2021-11-18 20:13:51 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-11-19 07:33:15 +0100 |
commit | 4d3e4c1cf3f117b8abd8dd67843864bb4c2e5a2f (patch) | |
tree | 79407be31ad906bd98bd09400619c3e2c29262ba /tools | |
parent | 6f3c6b12eaf0466827c9ec6b84c2516e38061b04 (diff) |
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 <noel.grandin@collabora.co.uk>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/source/stream/strmunx.cxx | 11 |
1 files changed, 7 insertions, 4 deletions
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 <osl/file.hxx> #include <osl/detail/file.h> -#include <rtl/instance.hxx> 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<SvFileStream const *, osl::DirectoryItem> 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); } |