00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
#ifndef WT_OS_BASE_H
00023
#define WT_OS_BASE_H
00024
00025
#include <wefts_cleanup.h>
00026
#include <string>
00027
00042
namespace Wefts {
00043
00052 typedef enum
00053 {
00059 PrioRealTime = 0,
00065 PrioHigh = 1,
00072 PrioNormal = 2,
00079 PrioLow = 3,
00086 PrioIdle = 4
00087 } OSPriority ;
00088
00100 typedef struct tag_ThreadAndReturn
00101 {
00102 void *
thread;
00103 void *
runReturn;
00104 }
ThreadAndReturn;
00105
00112 class OSMutexBase {
00113
protected:
00115 OSMutexBase(){}
00116
00117
public:
00119
virtual inline void lock()=0;
00120
00122
virtual inline bool trylock()=0;
00123
00125
virtual inline void unlock()=0;
00126 };
00127
00143 class OSConditionBase {
00144
protected:
00146 OSConditionBase() {}
00147
00148
public:
00152
virtual void signal()=0;
00153
00157
virtual void signalOne()=0;
00158
00172
virtual bool wait(
OSMutexBase &mtx,
CleanupItem &guard )=0;
00173
00182
virtual bool timedWait(
OSMutexBase &mtx,
long seconds,
00183
long nanoseconds,
CleanupItem &guard )=0;
00184 };
00185
00191 class OSThreadBase {
00192
protected:
00197 OSThreadBase() {}
00198
00203 OSThreadBase(
bool ) {}
00204
00205
protected:
00210
virtual void exit(
void *data )=0;
00211
00212
public:
00245
virtual bool priority( OSPriority prio_class,
int boost = 0) = 0;
00246
00253
virtual bool start(
void *(*func)(
void *),
void *data )=0;
00254
00256
virtual bool stop()=0;
00257
00259
virtual void *
join()=0;
00260
00268
virtual int enableCancel()=0;
00269
00274
virtual int disableCancel()=0;
00275
00283
virtual bool setCancelState(
int state )=0;
00284
00286
virtual void testCancel()=0;
00293
virtual void setCancelDeferred()=0;
00294
00301
virtual void detach()=0;
00302
00308 virtual void emuDeferredStart() {}
00309
00315 virtual void emuDeferredEnd() {}
00316
00342
virtual void *osRun(
void * (*func)(
void *),
void *data,
void (*cleanup)(
void *) )=0;
00343
00346
virtual bool same() const=0;
00347
00349 virtual
bool equal( const
OSThreadBase &th ) const =0;
00350
00357 virtual
bool setCurrent()=0;
00358
00359
00360
00361
00362
00363
00364 virtual
void invalidate()=0;
00365
00367 virtual
bool operator==(
OSThreadBase &th ) {
return equal( th ); }
00368
00370 virtual bool operator!=(
OSThreadBase &th ) {
return !
equal( th ); }
00371 };
00372
00374 class OSSpecificDataBase
00375 {
00376
protected:
00378 OSSpecificDataBase() {}
00379
00380
public:
00381
00383
virtual void *
data() const =0;
00384
00386 virtual
void data(const
void *dt) =0;
00387 };
00388
00389
00391 std::string OSErrorDescription(
int osCode );
00392
00394
bool OSSleep(
long nSeconds,
long nNanoseconds );
00395
00405
void *getCurrentThreadObject();
00406
00412
void setCurrentThreadObject(
void *thread);
00413
00415 }
00416
00417 #endif
00418
00419