Home Information Classes Download Usage Mail List Requirements Links Tutorial

# Thread.h

    00001 /***************************************************/
    00012 /***************************************************/
    00013
    00014 #if !defined(__THREAD_H)
    00015 #define __THREAD_H
    00016
    00017 #include "Stk.h"
    00018
    00019 #if (defined(__OS_IRIX__) || defined(__OS_LINUX__) || defined(__OS_MACOSX__))
    00020
    00021   #include <pthread.h>
    00022   #define THREAD_TYPE
    00023   typedef pthread_t THREAD_HANDLE;
    00024   typedef void * THREAD_RETURN;
    00025   typedef void * (*THREAD_FUNCTION)(void *);
    00026   typedef pthread_mutex_t MUTEX;
    00027
    00028 #elif defined(__OS_WINDOWS__)
    00029
    00030   #include <windows.h>
    00031   #include <process.h>
    00032   #define THREAD_TYPE __stdcall
    00033   typedef unsigned long THREAD_HANDLE;
    00034   typedef unsigned THREAD_RETURN;
    00035   typedef unsigned (__stdcall *THREAD_FUNCTION)(void *);
    00036   typedef CRITICAL_SECTION MUTEX;
    00037
    00038 #endif
    00039
    00040 class Thread : public Stk
    00041 {
    00042  public:
    00044   Thread();
    00045
    00047   ~Thread();
    00048
    00050
    00054   bool start( THREAD_FUNCTION routine, void * ptr = NULL );
    00055
    00057
    00063   bool wait( long milliseconds = -1 );
    00064
    00066   static void test(void);
    00067
    00068  protected:
    00069
    00070   THREAD_HANDLE thread;
    00071
    00072 };
    00073
    00074 class Mutex : public Stk
    00075 {
    00076  public:
    00078   Mutex();
    00079
    00081   ~Mutex();
    00082
    00084   void lock(void);
    00085
    00087   void unlock(void);
    00088
    00089  protected:
    00090
    00091   MUTEX mutex;
    00092
    00093 };
    00094
    00095 #endif // defined(__THREAD_H)

The Synthesis ToolKit in C++ (STK)
©1995-2004 Perry R. Cook and Gary P. Scavone. All Rights Reserved.