wefts_os_base.h

Go to the documentation of this file.
00001 /* 00002 wefts_os_base.h 00003 Abstract base class for os dependant implementations 00004 00005 $Id: wefts_os_base.h,v 1.12 2004/03/28 21:45:40 jonnymind Exp $ 00006 --------------------------------------------- 00007 Begin : 2003-08-15 16:30 00008 Author : Giancarlo Niccolai 00009 00010 Last modified because: 00011 00012 */ 00013 00014 /************************************************************************** 00015 * This program is free software; you can redistribute it and/or modify * 00016 * it under the terms of the GNU Library General Public License as * 00017 * published by the Free Software Foundation; either version 2.1 of the * 00018 * License, or (at your option) any later version. * 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 /* Invalidate current thread. 00360 This function must make so that the invalidated thread always returns 00361 false when same() or equal() are called. If equal() method is called 00362 upon another invalid thread, the result is undefined. 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 } // namespace 00416 00417 #endif 00418 00419 /* end of wefts_os_pthread.h */

Generated on Tue Oct 5 14:57:00 2004 for Wefts by doxygen 1.3.7