blob: b75378b88ba83028a35a47e265d1c87ea3e34300 (
plain)
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
|
#include <lib/base/thread.h>
#include <stdio.h>
#include <lib/base/eerror.h>
void *eThread::wrapper(void *ptr)
{
((eThread*)ptr)->thread();
pthread_exit(0);
}
eThread::eThread()
{
alive=0;
}
void eThread::run()
{
alive=1;
pthread_create(&the_thread, 0, wrapper, this);
}
eThread::~eThread()
{
if (alive)
kill();
}
void eThread::kill()
{
alive=0;
eDebug("waiting for thread shutdown");
pthread_join(the_thread, 0);
eDebug("ok");
}
void eThread::sendSignal(int sig)
{
if (alive)
pthread_kill(the_thread, sig);
}
|