From 0de7513cd73f1f35265e42f9a2b9befe81302c2c Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 22 Jul 2021 22:18:01 +0200 Subject: 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 --- svtools/source/control/asynclink.cxx | 21 ++++++++------------- svtools/source/control/inettbc.cxx | 2 -- 2 files changed, 8 insertions(+), 15 deletions(-) (limited to 'svtools/source/control') 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 ); } -- cgit