From 396138719206d5033faaeaf09b88437cbb3480e7 Mon Sep 17 00:00:00 2001 From: Chris Sherlock Date: Sat, 18 Mar 2017 18:32:13 +1100 Subject: salhelper: change oslCondition to osl::Condition Condition is deprecated already, but there is no need for the us 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 Change-Id: Ia362666ff241293e143de0fa1dc0bc3a990bef82 Reviewed-on: https://gerrit.libreoffice.org/35388 Reviewed-by: Chris Sherlock Tested-by: Chris Sherlock --- salhelper/source/condition.cxx | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'salhelper') diff --git a/salhelper/source/condition.cxx b/salhelper/source/condition.cxx index 61971def7509..1122fe8b32ff 100644 --- a/salhelper/source/condition.cxx +++ b/salhelper/source/condition.cxx @@ -33,14 +33,13 @@ using namespace salhelper; Condition::Condition(osl::Mutex& aMutex) : m_aMutex(aMutex), - m_aCondition(osl_createCondition()) + m_aCondition() { } Condition::~Condition() { - osl_destroyCondition(m_aCondition); } @@ -60,7 +59,7 @@ ConditionModifier::ConditionModifier(Condition& aCond) ConditionModifier::~ConditionModifier() { if(m_aCond.applies()) - osl_setCondition(m_aCond.m_aCondition); + m_aCond.m_aCondition.set(); m_aCond.m_aMutex.release(); } @@ -85,13 +84,13 @@ ConditionWaiter::ConditionWaiter(Condition& aCond) : m_aCond(aCond) { while(true) { - osl_waitCondition(m_aCond.m_aCondition,nullptr); + m_aCond.m_aCondition.wait(); m_aCond.m_aMutex.acquire(); if(m_aCond.applies()) break; else { - osl_resetCondition(m_aCond.m_aCondition); + m_aCond.m_aCondition.reset(); m_aCond.m_aMutex.release(); } } @@ -106,8 +105,8 @@ ConditionWaiter::ConditionWaiter(Condition& aCond,sal_uInt32 milliSec) aTime.Nanosec = 1000000 * ( milliSec % 1000 ); while(true) { - if( osl_waitCondition(m_aCond.m_aCondition,&aTime) == - osl_cond_result_timeout ) + if( m_aCond.m_aCondition.wait(&aTime) == + osl::Condition::result_timeout ) throw timedout(); m_aCond.m_aMutex.acquire(); @@ -115,7 +114,7 @@ ConditionWaiter::ConditionWaiter(Condition& aCond,sal_uInt32 milliSec) if(m_aCond.applies()) break; else { - osl_resetCondition(m_aCond.m_aCondition); + m_aCond.m_aCondition.reset(); m_aCond.m_aMutex.release(); } } @@ -125,7 +124,7 @@ ConditionWaiter::ConditionWaiter(Condition& aCond,sal_uInt32 milliSec) ConditionWaiter::~ConditionWaiter() { if(! m_aCond.applies()) - osl_resetCondition(m_aCond.m_aCondition); + m_aCond.m_aCondition.reset(); m_aCond.m_aMutex.release(); } -- cgit