00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
#ifndef _QUANTAPLUS_THREAD_C
00024
#define _QUANTAPLUS_THREAD_C
00025
00026
#include <QUANTA/QUANTAinit.hxx>
00027
#include <QUANTA/QUANTAglobals.hxx>
00028
00029
typedef void* (*QUANTA_THREADED_FUNC)(
void*);
00030
00031
#ifdef QUANTA_USE_PTHREADS
00032
typedef pthread_t QUANTA_THREAD_T;
00033
#elif defined(WIN32) && defined(QUANTA_USE_WINDOWSTHREADS)
00034
typedef unsigned QUANTA_THREAD_T;
00035
00036
00037
#else
00038
#error One of QUANTA_USE_PTHREADS or QUANTA_USE_WINDOWSTHREADS must be defined.
00039
#endif
00040
00041
00042
extern "C" void *entryPoint(
void *arg);
00043
00044
00051 class QUANTAts_thread_c {
00052
public:
00053
QUANTAts_thread_c(
void);
00054
virtual ~
QUANTAts_thread_c(
void);
00055
00056
00057
00058
00059
virtual void run(
void) {}
00060
00070
int create(
void * (*threaded_func)(
void *),
void *arg);
00071
void create(
void);
00072
00073
00075 QUANTA_THREAD_T *
getThread();
00076
00077
inline void start(
void) { _running = 1; }
00078
inline void stop(
void) { _running = 0; }
00079
00083 inline bool isRunning(
void)
const {
return _running; }
00084
00085
00090
bool detach(
void);
00091
00092
00097
bool join(
void);
00098
00099
00100
private:
00101 QUANTA_THREAD_T itsThread;
00102
bool _initted;
00103
bool _running;
00104 };
00105
00106
00107
#endif