diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2016-01-23 08:28:22 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2016-01-25 10:01:00 +0200 |
commit | 3dc37e975ee79c4fd4215cb14a074f1fb5a35ca4 (patch) | |
tree | e474b20f984e1eaaeab4fd637fa246a6ea972413 /vcl/osx | |
parent | 34378c7da67a2669f5dbbb0b1c52da0c3f6ccd00 (diff) |
more usage of C++ osl::Mutex, osl::MutexGuard
Change-Id: Ibdc54fdccf70a9d60ad0fdcb9898bcd6d7bda368
Diffstat (limited to 'vcl/osx')
-rw-r--r-- | vcl/osx/salinst.cxx | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/vcl/osx/salinst.cxx b/vcl/osx/salinst.cxx index 41ad480e50a4..2e3fdadd2e00 100644 --- a/vcl/osx/salinst.cxx +++ b/vcl/osx/salinst.cxx @@ -349,13 +349,13 @@ void DestroySalInstance( SalInstance* pInst ) } AquaSalInstance::AquaSalInstance() + : maUserEventListMutex() { mpSalYieldMutex = new SalYieldMutex; mpSalYieldMutex->acquire(); ::comphelper::SolarMutex::setSolarMutex( mpSalYieldMutex ); maMainThread = osl::Thread::getCurrentIdentifier(); mbWaitingYield = false; - maUserEventListMutex = osl_createMutex(); mnActivePrintJobs = 0; maWaitingYieldCond = osl_createCondition(); } @@ -365,7 +365,6 @@ AquaSalInstance::~AquaSalInstance() ::comphelper::SolarMutex::setSolarMutex( nullptr ); mpSalYieldMutex->release(); delete mpSalYieldMutex; - osl_destroyMutex( maUserEventListMutex ); osl_destroyCondition( maWaitingYieldCond ); } @@ -391,10 +390,10 @@ void AquaSalInstance::wakeupYield() void AquaSalInstance::PostUserEvent( AquaSalFrame* pFrame, sal_uInt16 nType, void* pData ) { - osl_acquireMutex( maUserEventListMutex ); - maUserEvents.push_back( SalUserEvent( pFrame, pData, nType ) ); - osl_releaseMutex( maUserEventListMutex ); - + { + osl::MutexGuard g( maUserEventListMutex ); + maUserEvents.push_back( SalUserEvent( pFrame, pData, nType ) ); + } // notify main loop that an event has arrived wakeupYield(); } @@ -582,17 +581,17 @@ SalYieldResult AquaSalInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents sal_uLong nCount = ReleaseYieldMutex(); // get one user event - osl_acquireMutex( maUserEventListMutex ); SalUserEvent aEvent( nullptr, nullptr, 0 ); - if( ! maUserEvents.empty() ) { - aEvent = maUserEvents.front(); - maUserEvents.pop_front(); + osl::MutexGuard g( maUserEventListMutex ); + if( ! maUserEvents.empty() ) + { + aEvent = maUserEvents.front(); + maUserEvents.pop_front(); + } + else + bDispatchUser = false; } - else - bDispatchUser = false; - osl_releaseMutex( maUserEventListMutex ); - AcquireYieldMutex( nCount ); // dispatch it |