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:
committed by
Noel Grandin
parent
39aa29712f
commit
d220fc00c2
@@ -19,16 +19,17 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "pppoptimizertoken.hxx"
|
#include "pppoptimizertoken.hxx"
|
||||||
#include <osl/mutex.hxx>
|
|
||||||
#include <sal/macros.h>
|
#include <sal/macros.h>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <mutex>
|
||||||
|
|
||||||
typedef std::unordered_map< const char*, PPPOptimizerTokenEnum, rtl::CStringHash, rtl::CStringEqual> TypeNameHashMap;
|
typedef std::unordered_map< const char*, PPPOptimizerTokenEnum, rtl::CStringHash, rtl::CStringEqual> TypeNameHashMap;
|
||||||
static TypeNameHashMap* pHashMap = nullptr;
|
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;
|
return s_aHashMapProtection;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,7 +167,7 @@ PPPOptimizerTokenEnum TKGet( const OUString& rToken )
|
|||||||
{
|
{
|
||||||
if ( !pHashMap )
|
if ( !pHashMap )
|
||||||
{ // init hash map
|
{ // init hash map
|
||||||
::osl::MutexGuard aGuard( getHashMapMutex() );
|
std::lock_guard aGuard( getHashMapMutex() );
|
||||||
if ( !pHashMap )
|
if ( !pHashMap )
|
||||||
{
|
{
|
||||||
TypeNameHashMap* pH = new TypeNameHashMap;
|
TypeNameHashMap* pH = new TypeNameHashMap;
|
||||||
|
@@ -20,6 +20,7 @@
|
|||||||
#include <sal/config.h>
|
#include <sal/config.h>
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
#include <mutex>
|
||||||
|
|
||||||
#include <pdfihelper.hxx>
|
#include <pdfihelper.hxx>
|
||||||
|
|
||||||
@@ -44,7 +45,7 @@ class PDFPasswordRequest:
|
|||||||
task::XInteractionRequest, task::XInteractionPassword >
|
task::XInteractionRequest, task::XInteractionPassword >
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
mutable osl::Mutex m_aMutex;
|
mutable std::mutex m_aMutex;
|
||||||
uno::Any m_aRequest;
|
uno::Any m_aRequest;
|
||||||
OUString m_aPassword;
|
OUString m_aPassword;
|
||||||
bool m_bSelected;
|
bool m_bSelected;
|
||||||
@@ -65,7 +66,7 @@ public:
|
|||||||
// XInteractionContinuation
|
// XInteractionContinuation
|
||||||
virtual void SAL_CALL select() override;
|
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:
|
private:
|
||||||
virtual ~PDFPasswordRequest() override {}
|
virtual ~PDFPasswordRequest() override {}
|
||||||
@@ -98,21 +99,21 @@ uno::Sequence< uno::Reference< task::XInteractionContinuation > > PDFPasswordReq
|
|||||||
|
|
||||||
void PDFPasswordRequest::setPassword( const OUString& rPwd )
|
void PDFPasswordRequest::setPassword( const OUString& rPwd )
|
||||||
{
|
{
|
||||||
osl::MutexGuard const guard( m_aMutex );
|
std::scoped_lock const guard( m_aMutex );
|
||||||
|
|
||||||
m_aPassword = rPwd;
|
m_aPassword = rPwd;
|
||||||
}
|
}
|
||||||
|
|
||||||
OUString PDFPasswordRequest::getPassword()
|
OUString PDFPasswordRequest::getPassword()
|
||||||
{
|
{
|
||||||
osl::MutexGuard const guard( m_aMutex );
|
std::scoped_lock const guard( m_aMutex );
|
||||||
|
|
||||||
return m_aPassword;
|
return m_aPassword;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PDFPasswordRequest::select()
|
void PDFPasswordRequest::select()
|
||||||
{
|
{
|
||||||
osl::MutexGuard const guard( m_aMutex );
|
std::scoped_lock const guard( m_aMutex );
|
||||||
|
|
||||||
m_bSelected = true;
|
m_bSelected = true;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user