Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

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.4 2003/12/14 09:07:55 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 
00054 class OSMutexBase {
00055 protected:
00057    OSMutexBase(){}
00058 
00059 public:
00061    virtual inline void lock()=0;
00062 
00064    virtual inline bool trylock()=0;
00065 
00067    virtual inline void unlock()=0;
00068 };
00069 
00085 class OSConditionBase {
00086 protected:
00088    OSConditionBase() {}
00089 
00090 public:
00092    virtual void signal()=0;
00093 
00107    virtual bool wait( OSMutexBase &mtx, CleanupItem guard )=0;
00108 
00117    virtual bool timedWait( OSMutexBase &mtx, long seconds,
00118          long nanoseconds, CleanupItem guard )=0;
00119 };
00120 
00126 class OSThreadBase {
00127 protected:
00132    OSThreadBase() {}
00133 
00138    OSThreadBase( bool ) {}
00139 
00140 protected:
00145    virtual void exit( void *data )=0;
00146 
00147 public:
00154    virtual bool start( void *(*func)(void *), void *data )=0;
00155 
00157    virtual bool stop()=0;
00158 
00160    virtual void *join()=0;
00161 
00169    virtual int enableCancel()=0;
00170 
00175    virtual int disableCancel()=0;
00176 
00184    virtual bool setCancelState( int state )=0;
00185 
00187    virtual void testCancel()=0;
00194    virtual void setCancelDeferred()=0;
00195    
00202    virtual void detach()=0;
00203 
00209    virtual void emuDeferredStart() {}
00210    
00216    virtual void emuDeferredEnd() {}
00217 
00230    virtual void osRun( void (*func)(void *), void *data, void (*cleanup)(void *) )=0;
00231 
00234    virtual bool same() const=0;
00235 
00237    virtual bool equal( const OSThreadBase &th ) const =0;
00238 
00245    virtual bool setCurrent()=0;
00246 
00247    /* Invalidate current thread.
00248       This function must make so that the invalidated thread always returns
00249       false when same() or equal() are called. If equal() method is called
00250       upon another invalid thread, the result is undefined.
00251    */
00252    virtual void invalidate()=0;
00253 
00255    virtual bool operator==( OSThreadBase &th ) { return equal( th ); }
00256 
00258    virtual bool operator!=( OSThreadBase &th ) { return ! equal( th ); }
00259 };
00260 
00262 class OSSpecificDataBase
00263 {
00264 protected:
00266    OSSpecificDataBase() {}
00267 
00268 public:
00269 
00271    virtual void *data() const =0;
00272 
00274    virtual void data(const void *dt) =0;
00275 };
00276 
00277 
00279 std::string OSErrorDescription( int osCode );
00280 
00282 bool OSSleep( long nSeconds, long nNanoseconds );
00283 
00284 
00286 } // namespace
00287 
00288 #endif
00289 
00290 /* end of wefts_os_pthread.h */

Generated on Mon Dec 22 04:12:30 2003 for Wefts by doxygen1.2.18