chart2/source/tools/LifeTime.cxx | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-)
New commits: commit b961e7c9ba88b2b84628f2482a5f23fe1f67369a Author: Stephan Bergmann <[email protected]> AuthorDate: Mon Sep 16 16:53:41 2019 +0200 Commit: Stephan Bergmann <[email protected]> CommitDate: Mon Sep 16 21:00:25 2019 +0200 Simplify some osl::Clearable/ResettableGuard (and use osl::MutexGuard typedef instead of osl::Guard<osl::Mutex>) Change-Id: Ib433bf978608081f7e3a2ff9671fe16a5b4f50e0 Reviewed-on: https://gerrit.libreoffice.org/79021 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <[email protected]> diff --git a/chart2/source/tools/LifeTime.cxx b/chart2/source/tools/LifeTime.cxx index 26e19b1a6b53..5ac9ba648e60 100644 --- a/chart2/source/tools/LifeTime.cxx +++ b/chart2/source/tools/LifeTime.cxx @@ -109,7 +109,7 @@ bool LifeTimeManager::dispose() { //hold no mutex { - osl::Guard< osl::Mutex > aGuard( m_aAccessMutex ); + osl::MutexGuard aGuard( m_aAccessMutex ); if( m_bDisposed || m_bInDispose ) { @@ -137,10 +137,9 @@ bool LifeTimeManager::dispose() //no mutex is acquired { - osl::ClearableGuard< osl::Mutex > aGuard( m_aAccessMutex ); + osl::MutexGuard aGuard( m_aAccessMutex ); OSL_ENSURE( !m_bDisposed, "dispose was called already" ); m_bDisposed = true; - aGuard.clear(); } //no mutex is acquired @@ -189,7 +188,7 @@ bool CloseableLifeTimeManager::g_close_startTryClose(bool bDeliverOwnership) { //no mutex is allowed to be acquired { - osl::ResettableGuard< osl::Mutex > aGuard( m_aAccessMutex ); + osl::MutexGuard aGuard( m_aAccessMutex ); if( impl_isDisposedOrClosed(false) ) return false; @@ -245,7 +244,7 @@ bool CloseableLifeTimeManager::g_close_startTryClose(bool bDeliverOwnership) void CloseableLifeTimeManager::g_close_endTryClose(bool bDeliverOwnership ) { //this method is called, if the try to close was not successful - osl::Guard< osl::Mutex > aGuard( m_aAccessMutex ); + osl::MutexGuard aGuard( m_aAccessMutex ); impl_setOwnership( bDeliverOwnership, false ); m_bInTryClose = false; @@ -263,7 +262,7 @@ void CloseableLifeTimeManager::g_close_isNeedToCancelLongLastingCalls( bool bDel //it returns true, if some longlasting calls are running, which might be cancelled //it throws the given exception, if long calls are running but not cancelable - osl::Guard< osl::Mutex > aGuard( m_aAccessMutex ); + osl::MutexGuard aGuard( m_aAccessMutex ); //this count cannot grow after try of close has started, because we wait in all those methods for end of try closing if( !m_nLongLastingCallCount ) return; @@ -283,7 +282,7 @@ void CloseableLifeTimeManager::g_close_isNeedToCancelLongLastingCalls( bool bDel void CloseableLifeTimeManager::g_close_endTryClose_doClose() { //this method is called, if the try to close was successful - osl::ResettableGuard< osl::Mutex > aGuard( m_aAccessMutex ); + osl::MutexGuard aGuard( m_aAccessMutex ); m_bInTryClose = false; m_aEndTryClosingCondition.set(); @@ -362,7 +361,7 @@ void CloseableLifeTimeManager::impl_doClose() void CloseableLifeTimeManager::g_addCloseListener( const uno::Reference< util::XCloseListener > & xListener ) { - osl::Guard< osl::Mutex > aGuard( m_aAccessMutex ); + osl::MutexGuard aGuard( m_aAccessMutex ); //Mutex needs to be acquired exactly once; will be released inbetween if( !impl_canStartApiCall() ) return; commit c31a1bc4fad33451a25265be90f0ef9d6ea3bb91 Author: Stephan Bergmann <[email protected]> AuthorDate: Mon Sep 16 16:49:52 2019 +0200 Commit: Stephan Bergmann <[email protected]> CommitDate: Mon Sep 16 21:00:15 2019 +0200 Typo "ones" -> "once" in comments Change-Id: I832d92e4ba1799869f4ebbb5451e9a80e28bb573 Reviewed-on: https://gerrit.libreoffice.org/79020 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <[email protected]> diff --git a/chart2/source/tools/LifeTime.cxx b/chart2/source/tools/LifeTime.cxx index 5a7a10b37307..26e19b1a6b53 100644 --- a/chart2/source/tools/LifeTime.cxx +++ b/chart2/source/tools/LifeTime.cxx @@ -86,7 +86,7 @@ void LifeTimeManager::impl_registerApiCall(bool bLongLastingCall) void LifeTimeManager::impl_unregisterApiCall(bool bLongLastingCall) { - //Mutex needs to be acquired exactly ones + //Mutex needs to be acquired exactly once //mutex may be released inbetween in special case of impl_apiCallCountReachedNull() OSL_ENSURE( m_nAccessCount>0, "access count mismatch" ); @@ -193,7 +193,7 @@ bool CloseableLifeTimeManager::g_close_startTryClose(bool bDeliverOwnership) if( impl_isDisposedOrClosed(false) ) return false; - //Mutex needs to be acquired exactly ones; will be released inbetween + //Mutex needs to be acquired exactly once; will be released inbetween if( !impl_canStartApiCall() ) return false; //mutex is acquired @@ -251,7 +251,7 @@ void CloseableLifeTimeManager::g_close_endTryClose(bool bDeliverOwnership ) m_bInTryClose = false; m_aEndTryClosingCondition.set(); - //Mutex needs to be acquired exactly ones + //Mutex needs to be acquired exactly once //mutex may be released inbetween in special case of impl_apiCallCountReachedNull() impl_unregisterApiCall(false); } @@ -273,7 +273,7 @@ void CloseableLifeTimeManager::g_close_isNeedToCancelLongLastingCalls( bool bDel m_bInTryClose = false; m_aEndTryClosingCondition.set(); - //Mutex needs to be acquired exactly ones + //Mutex needs to be acquired exactly once //mutex may be released inbetween in special case of impl_apiCallCountReachedNull() impl_unregisterApiCall(false); @@ -288,7 +288,7 @@ void CloseableLifeTimeManager::g_close_endTryClose_doClose() m_bInTryClose = false; m_aEndTryClosingCondition.set(); - //Mutex needs to be acquired exactly ones + //Mutex needs to be acquired exactly once //mutex may be released inbetween in special case of impl_apiCallCountReachedNull() impl_unregisterApiCall(false); impl_doClose(); @@ -301,7 +301,7 @@ void CloseableLifeTimeManager::impl_setOwnership( bool bDeliverOwnership, bool b void CloseableLifeTimeManager::impl_apiCallCountReachedNull() { - //Mutex needs to be acquired exactly ones + //Mutex needs to be acquired exactly once //mutex will be released inbetween in impl_doClose() if( m_pCloseable && m_bOwnership ) impl_doClose(); @@ -309,7 +309,7 @@ void CloseableLifeTimeManager::impl_apiCallCountReachedNull() void CloseableLifeTimeManager::impl_doClose() { - //Mutex needs to be acquired exactly ones before calling impl_doClose() + //Mutex needs to be acquired exactly once before calling impl_doClose() if(m_bClosed) return; //behave as passive as possible, if disposed or closed already @@ -363,7 +363,7 @@ void CloseableLifeTimeManager::impl_doClose() void CloseableLifeTimeManager::g_addCloseListener( const uno::Reference< util::XCloseListener > & xListener ) { osl::Guard< osl::Mutex > aGuard( m_aAccessMutex ); - //Mutex needs to be acquired exactly ones; will be released inbetween + //Mutex needs to be acquired exactly once; will be released inbetween if( !impl_canStartApiCall() ) return; //mutex is acquired @@ -374,7 +374,7 @@ void CloseableLifeTimeManager::g_addCloseListener( const uno::Reference< util::X bool CloseableLifeTimeManager::impl_canStartApiCall() { - //Mutex needs to be acquired exactly ones before calling this method + //Mutex needs to be acquired exactly once before calling this method //the mutex will be released inbetween and reacquired if( impl_isDisposed() ) @@ -401,14 +401,14 @@ bool CloseableLifeTimeManager::impl_canStartApiCall() bool LifeTimeGuard::startApiCall(bool bLongLastingCall) { - //Mutex needs to be acquired exactly ones; will be released inbetween + //Mutex needs to be acquired exactly once; will be released inbetween //mutex is required due to constructor of LifeTimeGuard OSL_ENSURE( !m_bCallRegistered, "this method is only allowed ones" ); if(m_bCallRegistered) return false; - //Mutex needs to be acquired exactly ones; will be released inbetween + //Mutex needs to be acquired exactly once; will be released inbetween if( !m_rManager.impl_canStartApiCall() ) return false; //mutex is acquired @@ -427,7 +427,7 @@ LifeTimeGuard::~LifeTimeGuard() osl::MutexGuard g(m_rManager.m_aAccessMutex); if(m_bCallRegistered) { - //Mutex needs to be acquired exactly ones + //Mutex needs to be acquired exactly once //mutex may be released inbetween in special case of impl_apiCallCountReachedNull() m_rManager.impl_unregisterApiCall(m_bLongLastingCallRegistered); } _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
