Kaydet (Commit) 2667435e authored tarafından Chris Sherlock's avatar Chris Sherlock

vcl: have AcquaSalInstance use osl::Condition instead of oslCondition

Condition is deprecated already, but there is no need for the
AcquaSalInstance class to use the low-level C-API, when in fact there
is a C++ fascade that calls on this via the C++ abstraction,
osl::Condition.

This will make it much easier to switch to using std::condition_variable
in the future.

Change-Id: Ic495c4120a59480bf50a8c5b73608874fc4228ea
Reviewed-on: https://gerrit.libreoffice.org/35392Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarChris Sherlock <chris.sherlock79@gmail.com>
üst 96a9b38d
...@@ -28,6 +28,11 @@ ...@@ -28,6 +28,11 @@
#include <osl/conditn.h> #include <osl/conditn.h>
#if defined(MACOSX) && defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES)
# if __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES == 1
# undef check
# endif
#endif
namespace osl namespace osl
{ {
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include <list> #include <list>
#include <comphelper/solarmutex.hxx> #include <comphelper/solarmutex.hxx>
#include <osl/conditn.h> #include <osl/conditn.hxx>
#include <osl/thread.hxx> #include <osl/thread.hxx>
#ifdef MACOSX #ifdef MACOSX
...@@ -73,7 +73,7 @@ public: ...@@ -73,7 +73,7 @@ public:
int mnActivePrintJobs; int mnActivePrintJobs;
std::list< SalUserEvent > maUserEvents; std::list< SalUserEvent > maUserEvents;
osl::Mutex maUserEventListMutex; osl::Mutex maUserEventListMutex;
oslCondition maWaitingYieldCond; osl::Condition maWaitingYieldCond;
static std::list<const ApplicationEvent*> aAppEventList; static std::list<const ApplicationEvent*> aAppEventList;
......
...@@ -349,6 +349,7 @@ void DestroySalInstance( SalInstance* pInst ) ...@@ -349,6 +349,7 @@ void DestroySalInstance( SalInstance* pInst )
AquaSalInstance::AquaSalInstance() AquaSalInstance::AquaSalInstance()
: maUserEventListMutex() : maUserEventListMutex()
, maWaitingYieldCond()
{ {
mpSalYieldMutex = new SalYieldMutex; mpSalYieldMutex = new SalYieldMutex;
mpSalYieldMutex->acquire(); mpSalYieldMutex->acquire();
...@@ -356,7 +357,6 @@ AquaSalInstance::AquaSalInstance() ...@@ -356,7 +357,6 @@ AquaSalInstance::AquaSalInstance()
maMainThread = osl::Thread::getCurrentIdentifier(); maMainThread = osl::Thread::getCurrentIdentifier();
mbWaitingYield = false; mbWaitingYield = false;
mnActivePrintJobs = 0; mnActivePrintJobs = 0;
maWaitingYieldCond = osl_createCondition();
} }
AquaSalInstance::~AquaSalInstance() AquaSalInstance::~AquaSalInstance()
...@@ -364,7 +364,6 @@ AquaSalInstance::~AquaSalInstance() ...@@ -364,7 +364,6 @@ AquaSalInstance::~AquaSalInstance()
::comphelper::SolarMutex::setSolarMutex( nullptr ); ::comphelper::SolarMutex::setSolarMutex( nullptr );
mpSalYieldMutex->release(); mpSalYieldMutex->release();
delete mpSalYieldMutex; delete mpSalYieldMutex;
osl_destroyCondition( maWaitingYieldCond );
} }
void AquaSalInstance::wakeupYield() void AquaSalInstance::wakeupYield()
...@@ -600,7 +599,7 @@ SalYieldResult AquaSalInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents ...@@ -600,7 +599,7 @@ SalYieldResult AquaSalInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents
if( aEvent.mpFrame && AquaSalFrame::isAlive( aEvent.mpFrame ) ) if( aEvent.mpFrame && AquaSalFrame::isAlive( aEvent.mpFrame ) )
{ {
aEvent.mpFrame->CallCallback( aEvent.mnType, aEvent.mpData ); aEvent.mpFrame->CallCallback( aEvent.mnType, aEvent.mpData );
osl_setCondition( maWaitingYieldCond ); maWaitingYieldCond.set();
// return if only one event is asked for // return if only one event is asked for
if( ! bHandleAllCurrentEvents ) if( ! bHandleAllCurrentEvents )
return SalYieldResult::EVENT; return SalYieldResult::EVENT;
...@@ -683,17 +682,17 @@ SAL_WNODEPRECATED_DECLARATIONS_POP ...@@ -683,17 +682,17 @@ SAL_WNODEPRECATED_DECLARATIONS_POP
(*it)->maInvalidRect.SetEmpty(); (*it)->maInvalidRect.SetEmpty();
} }
} }
osl_setCondition( maWaitingYieldCond ); maWaitingYieldCond.set();
} }
else if( bWait ) else if( bWait )
{ {
// #i103162# // #i103162#
// wait until any thread (most likely the main thread) // wait until any thread (most likely the main thread)
// has dispatched an event, cop out at 200 ms // has dispatched an event, cop out at 200 ms
osl_resetCondition( maWaitingYieldCond ); maWaitingYieldCond.reset();
TimeValue aVal = { 0, 200000000 }; TimeValue aVal = { 0, 200000000 };
sal_uLong nCount = ReleaseYieldMutex(); sal_uLong nCount = ReleaseYieldMutex();
osl_waitCondition( maWaitingYieldCond, &aVal ); maWaitingYieldCond.wait( &aVal );
AcquireYieldMutex( nCount ); AcquireYieldMutex( nCount );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment