Home Information Classes Download Usage Mail List Requirements Links FAQ Tutorial

Thread.h
1#ifndef STK_THREAD_H
2#define STK_THREAD_H
3
4#include "Stk.h"
5
6#if (defined(__OS_IRIX__) || defined(__OS_LINUX__) || defined(__OS_MACOSX__))
7
8 #include <pthread.h>
9 #define THREAD_TYPE
10 typedef pthread_t THREAD_HANDLE;
11 typedef void * THREAD_RETURN;
12 typedef void * (*THREAD_FUNCTION)(void *);
13
14#elif defined(__OS_WINDOWS__)
15
16 #include <windows.h>
17 #include <process.h>
18 #define THREAD_TYPE __stdcall
19 typedef unsigned long THREAD_HANDLE;
20 typedef unsigned THREAD_RETURN;
21 typedef unsigned (__stdcall *THREAD_FUNCTION)(void *);
22
23#endif
24
25 namespace stk {
26
27/***************************************************/
47/***************************************************/
48
49 class Thread : public Stk
50{
51 public:
53 Thread();
54
56 ~Thread();
57
59
64 bool start( THREAD_FUNCTION routine, void * ptr = NULL );
65
67
74 bool cancel(void);
75
77
80 bool wait(void);
81
83
88 void testCancel(void);
89
90 protected:
91
92 THREAD_HANDLE thread_;
93
94};
95
96} // stk namespace
97
98#endif
stk::Stk::Stk
Stk(void)
Default constructor.
stk::Thread::testCancel
void testCancel(void)
Create a cancellation point within a thread routine.
stk::Thread::Thread
Thread()
Default constructor.
stk::Thread::cancel
bool cancel(void)
Signal cancellation of a thread routine, returning true on success.
stk::Thread::start
bool start(THREAD_FUNCTION routine, void *ptr=NULL)
Begin execution of the thread routine. Upon success, true is returned.
stk::Thread::wait
bool wait(void)
Block the calling routine indefinitely until the thread terminates.
stk::Thread::~Thread
~Thread()
The class destructor does not attempt to cancel or join a thread.
stk
The STK namespace.
Definition ADSR.h:6

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