summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2021-08-02 19:56:16 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-08-03 08:49:41 +0200
commit883a208bf4a705fde50e51428a8c8e5685ab91d4 (patch)
tree325bc62b8338fc18abb2a87e20c9d5b4c95389ee
parentc5c996578a62afda92fbf6211e9c9169167cc410 (diff)
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 <noel.grandin@collabora.co.uk>
-rw-r--r--svx/source/form/ParseContext.cxx22
1 files changed, 10 insertions, 12 deletions
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 <unotools/syslocale.hxx>
#include <vcl/svapp.hxx>
#include <osl/diagnose.h>
-#include <osl/mutex.hxx>
#include <fmstring.hrc>
+#include <mutex>
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);
}