tools/source/stream/strmunx.cxx |   11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

New commits:
commit 4d3e4c1cf3f117b8abd8dd67843864bb4c2e5a2f
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Thu Nov 18 20:13:51 2021 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Fri Nov 19 07:33:15 2021 +0100

    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.gran...@collabora.co.uk>

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);
 }
 

Reply via email to