1 #ifndef _included_thread
2 #define _included_thread
6 #define ThreadId Tcl_ThreadId
7 #define tMutex Tcl_Mutex
8 #define mutexInit(m) m = NULL
9 #define mutexDestroy(m) Tcl_MutexFinalize(&m)
10 #define mutexLock(m) (Tcl_MutexLock(&m), 0)
11 #define mutexUnlock(m) (Tcl_MutexUnlock(&m), 0)
12 #define threadCreate(p,fn,dt) Tcl_CreateThread(&p,v##fn,dt,TCL_THREAD_STACK_DEFAULT,0)
16 #define ThreadId pthread_t
17 #define tMutex pthread_mutex_t
18 #define mutexInit(m) pthread_mutex_init(&m,0)
19 #define mutexDestroy(m) pthread_mutex_destroy(&m)
20 #define mutexLock(m) pthread_mutex_lock(&m)
21 #define mutexUnlock(m) pthread_mutex_unlock(&m)
22 #define threadCreate(p,fn,dt) pthread_create(&p,0,fn,dt)
23 #define threadKill(p) pthread_kill(p,SIGQUIT)
32 static void *ThreadProc (void *);
33 friend void vThreadProc (void *param) { ThreadProc(param); }
34 public: Thread ():running (false)
54 virtual void Proc () = 0;
55 void Lock() { mutexLock(mutex); }
56 void Unlock() { mutexUnlock(mutex); }