1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
class CThread
{
private:
int hThread;
pthread_t ThreadId;
long Stacksize;
bool Detach;
int Priority;
//thread
friend void * Thread(void *);
protected:
//fonction virtuelle appelée par le thread
virtual void Run(void) = 0;
static void Exit()
{ pthread_exit(0);}
int setcancelstate(int state);
void setcancelpoint();
int setcanceltype(int type);
public:
CMutex *mutex;
//constructeur
CThread(int _priority = 1, long _stacksize = 2048, bool _detach = true, CMutex * mutex = NULL);
//destructeur
~CThread();
//lancer le thread
void Start(void);
//terminer le thread (brutal)
void Terminate(void);
//retourne l'activité du thread
bool IsRunning(void) const;
//retourne le handle du thread
int GetHandle(void) const;
//retourne l'identifiant du thread
pthread_t GetID(void) const;
//joindre le thread si il n'est pas detache
int join();
//attacher un mutex au thread
void SetMutex(CMutex * _mutex);
//attend la fin du thread
//long Wait(long dwTimeOut) const;
}; |
Partager