include/svtools/asynclink.hxx | 6 ++---- sfx2/source/doc/docfile.cxx | 1 - svtools/source/control/asynclink.cxx | 21 ++++++++------------- svtools/source/control/inettbc.cxx | 2 -- 4 files changed, 10 insertions(+), 20 deletions(-)
New commits: commit 0de7513cd73f1f35265e42f9a2b9befe81302c2c Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Thu Jul 22 22:18:01 2021 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Fri Jul 23 11:33:37 2021 +0200 osl::Mutex->std::mutex in AsynchronLink and inline the mutex since the only two users of this class both want the mutex Change-Id: I7821d67ad77e08059ef2fe6ccc6cc06570e8070b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119393 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/include/svtools/asynclink.hxx b/include/svtools/asynclink.hxx index 468f2a722548..bc0c742a4b4e 100644 --- a/include/svtools/asynclink.hxx +++ b/include/svtools/asynclink.hxx @@ -23,8 +23,7 @@ #include <svtools/svtdllapi.h> #include <tools/link.hxx> #include <vcl/idle.hxx> -#include <osl/mutex.hxx> -#include <memory> +#include <mutex> class Timer; struct ImplSVEvent; @@ -38,7 +37,7 @@ class UNLESS_MERGELIBS(SVT_DLLPUBLIC) AsynchronLink bool _bInCall; bool* _pDeleted; void* _pArg; - std::unique_ptr<::osl::Mutex> _pMutex; + std::mutex _aMutex; DECL_DLLPRIVATE_LINK( HandleCall_Idle, Timer*, void ); DECL_DLLPRIVATE_LINK( HandleCall_PostUserEvent, void*, void ); @@ -60,7 +59,6 @@ public: {} ~AsynchronLink(); - void CreateMutex(); void operator=( const Link<void*,void>& rLink ) { _aLink = rLink; } void Call( void* pObj, bool bAllowDoubles = false ); void ClearPendingCall( ); diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx index c7655e2c5f62..b9e089eb8b82 100644 --- a/sfx2/source/doc/docfile.cxx +++ b/sfx2/source/doc/docfile.cxx @@ -462,7 +462,6 @@ SfxMedium_Impl::SfxMedium_Impl() : nLastStorageError( ERRCODE_NONE ), m_nSignatureState( SignatureState::NOSIGNATURES ) { - aDoneLink.CreateMutex(); } diff --git a/svtools/source/control/asynclink.cxx b/svtools/source/control/asynclink.cxx index 49ebadb062c1..d1a111744691 100644 --- a/svtools/source/control/asynclink.cxx +++ b/svtools/source/control/asynclink.cxx @@ -28,11 +28,6 @@ namespace svtools { -void AsynchronLink::CreateMutex() -{ - if( !_pMutex ) _pMutex.reset( new osl::Mutex ); -} - void AsynchronLink::Call( void* pObj, bool bAllowDoubles ) { SAL_INFO_IF( !_bInCall, "svtools", "Recursives Call. Eher ueber Timer. TLX Fragen" ); // Do NOT translate. This is a valuable historical artefact. @@ -41,9 +36,8 @@ void AsynchronLink::Call( void* pObj, bool bAllowDoubles ) _pArg = pObj; DBG_ASSERT( bAllowDoubles || !_nEventId, "Already made a call" ); ClearPendingCall(); - if( _pMutex ) _pMutex->acquire(); + std::lock_guard aGuard(_aMutex); _nEventId = Application::PostUserEvent( LINK( this, AsynchronLink, HandleCall_PostUserEvent) ); - if( _pMutex ) _pMutex->release(); } } @@ -54,14 +48,16 @@ AsynchronLink::~AsynchronLink() Application::RemoveUserEvent( _nEventId ); } if( _pDeleted ) *_pDeleted = true; - _pMutex.reset(); } IMPL_LINK_NOARG( AsynchronLink, HandleCall_Idle, Timer*, void ) { - if( _pMutex ) _pMutex->acquire(); - _nEventId = nullptr; - if( _pMutex ) _pMutex->release(); + { + std::lock_guard aGuard(_aMutex); + _nEventId = nullptr; + // need to release the lock before calling the client since + // the client may call back into us + } Call_Impl( _pArg ); } @@ -72,13 +68,12 @@ IMPL_LINK_NOARG( AsynchronLink, HandleCall_PostUserEvent, void*, void ) void AsynchronLink::ClearPendingCall() { - if( _pMutex ) _pMutex->acquire(); + std::lock_guard aGuard(_aMutex); if( _nEventId ) { Application::RemoveUserEvent( _nEventId ); _nEventId = nullptr; } - if( _pMutex ) _pMutex->release(); } void AsynchronLink::Call_Impl( void* pArg ) diff --git a/svtools/source/control/inettbc.cxx b/svtools/source/control/inettbc.cxx index c027e45ea129..fe61e4c28e25 100644 --- a/svtools/source/control/inettbc.cxx +++ b/svtools/source/control/inettbc.cxx @@ -127,8 +127,6 @@ SvtMatchContext_Impl::SvtMatchContext_Impl(SvtURLBox* pBoxP, const OUString& rTe , stopped_(false) , commandId_(0) { - aLink.CreateMutex(); - FillPicklist( aPickList ); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits