- add more python stuff
[enigma2.git] / lib / base / thread.cpp
1 #include <lib/base/thread.h>
2 #include <stdio.h>
3 #include <lib/base/eerror.h>
4
5 void *eThread::wrapper(void *ptr)
6 {
7         ((eThread*)ptr)->thread();
8         pthread_exit(0);
9 }
10
11 eThread::eThread()
12 {
13         alive=0;
14 }
15
16 void eThread::run()
17 {
18         alive=1;
19         pthread_create(&the_thread, 0, wrapper, this);
20 }
21
22 eThread::~eThread()
23 {
24         if (alive)
25                 kill();
26 }
27
28 void eThread::kill()
29 {
30         alive=0;
31         eDebug("waiting for thread shutdown");
32         pthread_join(the_thread, 0);
33         eDebug("ok");
34 }