From 883a208bf4a705fde50e51428a8c8e5685ab91d4 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Mon, 2 Aug 2021 19:56:16 +0200 Subject: osl::Mutex->std::mutex in OParseContextClient and remove the atomic, we don't need an atomic if we are using a mutex Change-Id: I4d3107111b92ebdaa1fe0c1182cdc532f60bc51b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119910 Tested-by: Jenkins Reviewed-by: Noel Grandin --- svx/source/form/ParseContext.cxx | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'svx') diff --git a/svx/source/form/ParseContext.cxx b/svx/source/form/ParseContext.cxx index d86892ac804a..e5e76229907d 100644 --- a/svx/source/form/ParseContext.cxx +++ b/svx/source/form/ParseContext.cxx @@ -28,8 +28,8 @@ #include #include #include -#include #include +#include using namespace svxform; using namespace ::connectivity; @@ -144,17 +144,13 @@ IParseContext::InternationalKeyCode OSystemParseContext::getIntlKeyCode(const OS namespace { - ::osl::Mutex& getSafetyMutex() + std::mutex& getSafetyMutex() { - static ::osl::Mutex s_aSafety; + static ::std::mutex s_aSafety; return s_aSafety; } - oslInterlockedCount& getCounter() - { - static oslInterlockedCount s_nCounter; - return s_nCounter; - } + int s_nCounter; OSystemParseContext* getSharedContext(OSystemParseContext* _pContext, bool _bSet) { @@ -177,8 +173,9 @@ namespace OParseContextClient::OParseContextClient() { - ::osl::MutexGuard aGuard( getSafetyMutex() ); - if ( 1 == osl_atomic_increment( &getCounter() ) ) + std::lock_guard aGuard( getSafetyMutex() ); + ++s_nCounter; + if ( 1 == s_nCounter ) { // first instance getSharedContext( new OSystemParseContext, false ); } @@ -187,8 +184,9 @@ OParseContextClient::OParseContextClient() OParseContextClient::~OParseContextClient() { - ::osl::MutexGuard aGuard( getSafetyMutex() ); - if ( 0 == osl_atomic_decrement( &getCounter() ) ) + std::lock_guard aGuard( getSafetyMutex() ); + --s_nCounter; + if ( 0 == s_nCounter ) delete getSharedContext(nullptr,true); } -- cgit