sdext : use std::mutex when possible

Change-Id: Ia610c0c46e017452db71945f6f53fedbcb6d1198
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116415
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Arnaud Versini 2021-05-30 19:32:41 +02:00 committed by Noel Grandin
parent 39aa29712f
commit d220fc00c2
2 changed files with 11 additions and 9 deletions

View File

@ -19,16 +19,17 @@
#include "pppoptimizertoken.hxx"
#include <osl/mutex.hxx>
#include <sal/macros.h>
#include <unordered_map>
#include <memory>
#include <mutex>
typedef std::unordered_map< const char*, PPPOptimizerTokenEnum, rtl::CStringHash, rtl::CStringEqual> TypeNameHashMap;
static TypeNameHashMap* pHashMap = nullptr;
static ::osl::Mutex& getHashMapMutex()
static std::mutex& getHashMapMutex()
{
static osl::Mutex s_aHashMapProtection;
static std::mutex s_aHashMapProtection;
return s_aHashMapProtection;
}
@ -166,7 +167,7 @@ PPPOptimizerTokenEnum TKGet( const OUString& rToken )
{
if ( !pHashMap )
{ // init hash map
::osl::MutexGuard aGuard( getHashMapMutex() );
std::lock_guard aGuard( getHashMapMutex() );
if ( !pHashMap )
{
TypeNameHashMap* pH = new TypeNameHashMap;

View File

@ -20,6 +20,7 @@
#include <sal/config.h>
#include <cassert>
#include <mutex>
#include <pdfihelper.hxx>
@ -44,7 +45,7 @@ class PDFPasswordRequest:
task::XInteractionRequest, task::XInteractionPassword >
{
private:
mutable osl::Mutex m_aMutex;
mutable std::mutex m_aMutex;
uno::Any m_aRequest;
OUString m_aPassword;
bool m_bSelected;
@ -65,7 +66,7 @@ public:
// XInteractionContinuation
virtual void SAL_CALL select() override;
bool isSelected() const { osl::MutexGuard const guard( m_aMutex ); return m_bSelected; }
bool isSelected() const { std::scoped_lock const guard( m_aMutex ); return m_bSelected; }
private:
virtual ~PDFPasswordRequest() override {}
@ -98,21 +99,21 @@ uno::Sequence< uno::Reference< task::XInteractionContinuation > > PDFPasswordReq
void PDFPasswordRequest::setPassword( const OUString& rPwd )
{
osl::MutexGuard const guard( m_aMutex );
std::scoped_lock const guard( m_aMutex );
m_aPassword = rPwd;
}
OUString PDFPasswordRequest::getPassword()
{
osl::MutexGuard const guard( m_aMutex );
std::scoped_lock const guard( m_aMutex );
return m_aPassword;
}
void PDFPasswordRequest::select()
{
osl::MutexGuard const guard( m_aMutex );
std::scoped_lock const guard( m_aMutex );
m_bSelected = true;
}