diff options
Diffstat (limited to 'vos')
-rw-r--r-- | vos/inc/vos/thread.hxx | 21 | ||||
-rw-r--r-- | vos/source/thread.cxx | 32 |
2 files changed, 35 insertions, 18 deletions
diff --git a/vos/inc/vos/thread.hxx b/vos/inc/vos/thread.hxx index 3f52bb950b1d..50ad3ee46c63 100644 --- a/vos/inc/vos/thread.hxx +++ b/vos/inc/vos/thread.hxx @@ -2,9 +2,9 @@ * * $RCSfile: thread.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: jl $ $Date: 2001-03-14 10:01:09 $ + * last change: $Author: obr $ $Date: 2001-05-14 09:43:12 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -71,6 +71,9 @@ #ifndef _OSL_THREAD_H_ # include <osl/thread.h> #endif +#ifndef _OSL_CONDITION_H_ +# include <osl/conditn.h> +#endif #ifndef _VOS_RUNNABLE_HXX_ # include <vos/runnable.hxx> #endif @@ -107,6 +110,8 @@ class OThread : public NAMESPACE_VOS(IRunnable), VOS_DECLARE_CLASSINFO(VOS_NAMESPACE(OThread, vos)); + oslCondition m_aCondition; + public: /** priority of thread. */ @@ -124,12 +129,12 @@ public: */ enum TThreadSleep { - TSleep_Normal = osl_Thread_SleepNormal, - TSleep_Cancel = osl_Thread_SleepCancel, - TSleep_Pending = osl_Thread_SleepPending, - TSleep_Active = osl_Thread_SleepActive, - TSleep_Error = osl_Thread_SleepError, - TSleep_Unknown = osl_Thread_SleepUnknown + TSleep_Normal, + TSleep_Cancel, + TSleep_Pending, + TSleep_Active, + TSleep_Error, + TSleep_Unknown }; typedef oslThreadIdentifier TThreadIdentifier; diff --git a/vos/source/thread.cxx b/vos/source/thread.cxx index d632bafa2a83..7a085fd8eaf6 100644 --- a/vos/source/thread.cxx +++ b/vos/source/thread.cxx @@ -2,9 +2,9 @@ * * $RCSfile: thread.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: jl $ $Date: 2001-03-14 10:01:10 $ + * last change: $Author: obr $ $Date: 2001-05-14 09:44:09 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -115,6 +115,7 @@ OThread::OThread() { m_hThread = 0; m_bTerminating = sal_False; + m_aCondition = osl_createCondition(); } OThread::~OThread() @@ -126,6 +127,8 @@ OThread::~OThread() osl_freeThreadHandle(m_hThread); } + + osl_destroyCondition( m_aCondition ); } sal_Bool OThread::create() @@ -187,12 +190,24 @@ void OThread::join() OThread::TThreadSleep OThread::sleep(const TimeValue& Delay) { - if(m_hThread) + TThreadSleep eRet; + + switch( osl_waitCondition( m_aCondition, &Delay ) ) { - return (TThreadSleep)osl_sleepThread(m_hThread, &Delay); + case osl_cond_result_ok: + eRet = TSleep_Normal; + break; + + case osl_cond_result_timeout: + eRet = TSleep_Cancel; + break; + + default: + eRet = TSleep_Error; + break; } - return TSleep_Error; + return eRet; } void OThread::wait(const TimeValue& Delay) { @@ -201,11 +216,8 @@ void OThread::wait(const TimeValue& Delay) { sal_Bool OThread::awake() { - if(m_hThread) { - return osl_awakeThread(m_hThread); - } - - return sal_False; + osl_setCondition( m_aCondition ); + return osl_resetCondition( m_aCondition ); } void OThread::terminate() |