[Libreoffice-commits] core.git: include/salhelper salhelper/source
Chris Sherlock
chris.sherlock79 at gmail.com
Sat Mar 18 08:24:47 UTC 2017
include/salhelper/condition.hxx | 6 +++---
salhelper/source/condition.cxx | 17 ++++++++---------
2 files changed, 11 insertions(+), 12 deletions(-)
New commits:
commit 396138719206d5033faaeaf09b88437cbb3480e7
Author: Chris Sherlock <chris.sherlock79 at gmail.com>
Date: Sat Mar 18 18:32:13 2017 +1100
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 <chris.sherlock79 at gmail.com>
Tested-by: Chris Sherlock <chris.sherlock79 at gmail.com>
diff --git a/include/salhelper/condition.hxx b/include/salhelper/condition.hxx
index 86e9223dad98..a124a65cb7bb 100644
--- a/include/salhelper/condition.hxx
+++ b/include/salhelper/condition.hxx
@@ -22,7 +22,7 @@
#define INCLUDED_SALHELPER_CONDITION_HXX
-#include <osl/conditn.h>
+#include <osl/conditn.hxx>
#include <osl/mutex.hxx>
#include <salhelper/salhelperdllapi.h>
@@ -53,8 +53,8 @@ namespace salhelper
Condition(Condition &) SAL_DELETED_FUNCTION;
void operator =(Condition &) SAL_DELETED_FUNCTION;
- osl::Mutex& m_aMutex;
- oslCondition m_aCondition;
+ osl::Mutex& m_aMutex;
+ osl::Condition m_aCondition;
};
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();
}
More information about the Libreoffice-commits
mailing list