Guitar
src
win32
thread.h
Go to the documentation of this file.
1
2
#ifndef __THREAD_H
3
#define __THREAD_H
4
5
#include <stdarg.h>
6
7
#ifdef WIN32
8
#include <windows.h>
9
#include <process.h>
10
#else
11
#include <pthread.h>
12
#endif
13
14
15
16
class
Thread
{
17
protected
:
18
public
:
19
volatile
bool
_interrupted
;
20
bool
_running
;
21
#ifdef WIN32
22
HANDLE
_thread_handle
;
23
static
unsigned
int
__stdcall
run_
(
void
*arg);
24
#else
25
pthread_t
_thread_handle
;
26
static
void
*
run_
(
void
*arg);
27
#endif
28
29
public
:
30
Thread
()
31
{
32
_interrupted
=
false
;
33
_running
=
false
;
34
_thread_handle
= 0;
35
}
36
virtual
~Thread
()
37
{
38
detach
();
39
}
40
protected
:
41
virtual
void
run
() = 0;
42
virtual
bool
interrupted
()
const
43
{
44
return
_interrupted
;
45
}
46
public
:
47
virtual
void
start
();
48
virtual
void
stop
();
49
virtual
void
join
();
50
virtual
void
terminate
();
51
virtual
void
detach
();
52
bool
running
()
const
53
{
54
return
_running
;
55
}
56
};
57
58
59
60
#endif
Thread::_thread_handle
pthread_t _thread_handle
Definition:
thread.h:25
Thread::detach
virtual void detach()
Definition:
thread.cpp:65
Thread::_interrupted
volatile bool _interrupted
Definition:
thread.h:19
Thread::run
virtual void run()=0
Thread::run_
static void * run_(void *arg)
Definition:
thread.cpp:12
Thread::join
virtual void join()
Definition:
thread.cpp:39
Thread::interrupted
virtual bool interrupted() const
Definition:
thread.h:42
Thread::start
virtual void start()
Definition:
thread.cpp:21
Thread::~Thread
virtual ~Thread()
Definition:
thread.h:36
Thread::_running
bool _running
Definition:
thread.h:20
Thread::running
bool running() const
Definition:
thread.h:52
Thread::Thread
Thread()
Definition:
thread.h:30
Thread::stop
virtual void stop()
Definition:
thread.cpp:34
Thread
Definition:
thread.h:16
thread.h
Thread::terminate
virtual void terminate()
Definition:
thread.cpp:52
Generated by
1.8.17