Home   Information   Classes   Download   Usage   Mail List   Requirements   Links   FAQ   Tutorial


Thread.h

00001 /***************************************************/
00021 /***************************************************/
00022 
00023 #ifndef STK_THREAD_H
00024 #define STK_THREAD_H
00025 
00026 #include "Stk.h"
00027 
00028 #if (defined(__OS_IRIX__) || defined(__OS_LINUX__) || defined(__OS_MACOSX__))
00029 
00030   #include <pthread.h>
00031   #define THREAD_TYPE
00032   typedef pthread_t THREAD_HANDLE;
00033   typedef void * THREAD_RETURN;
00034   typedef void * (*THREAD_FUNCTION)(void *);
00035 
00036 #elif defined(__OS_WINDOWS__)
00037 
00038   #include <windows.h>
00039   #include <process.h>
00040   #define THREAD_TYPE __stdcall
00041   typedef unsigned long THREAD_HANDLE;
00042   typedef unsigned THREAD_RETURN;
00043   typedef unsigned (__stdcall *THREAD_FUNCTION)(void *);
00044 
00045 #endif
00046 
00047 class Thread : public Stk
00048 {
00049  public:
00051   Thread();
00052 
00054   ~Thread();
00055 
00057 
00062   bool start( THREAD_FUNCTION routine, void * ptr = NULL );
00063 
00065 
00072   bool cancel(void);
00073 
00075 
00078   bool wait(void);
00079 
00081 
00086   void testCancel(void);
00087 
00088  protected:
00089 
00090   THREAD_HANDLE thread_;
00091 
00092 };
00093 
00094 #endif

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