blob: 4cff92596fea0633fe9b023f0cf15487f072858b (
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
|
#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");
}
|