summaryrefslogtreecommitdiff
path: root/svtools/source/control/asynclink.cxx
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2021-07-22 22:18:01 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-07-23 11:33:37 +0200
commit0de7513cd73f1f35265e42f9a2b9befe81302c2c (patch)
tree2aaba5295e7e7222c85bdbec3fb724302396b2b3 /svtools/source/control/asynclink.cxx
parent4e512171c21a193027c35d19a5273507a2725596 (diff)
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.grandin@collabora.co.uk>
Diffstat (limited to 'svtools/source/control/asynclink.cxx')
-rw-r--r--svtools/source/control/asynclink.cxx21
1 files changed, 8 insertions, 13 deletions
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 )