diff options
| author | Felix Domke <tmbinc@elitedvb.net> | 2003-10-17 15:36:42 +0000 |
|---|---|---|
| committer | Felix Domke <tmbinc@elitedvb.net> | 2003-10-17 15:36:42 +0000 |
| commit | d63d2c3c6cbbd574dda4f8b00ebe6c661735edd5 (patch) | |
| tree | 84d0cacfd0b6c1241c236c7860f7cbd7f26901bb /lib/base/thread.cpp | |
| download | enigma2-d63d2c3c6cbbd574dda4f8b00ebe6c661735edd5.tar.gz enigma2-d63d2c3c6cbbd574dda4f8b00ebe6c661735edd5.zip | |
import of enigma2
Diffstat (limited to 'lib/base/thread.cpp')
| -rw-r--r-- | lib/base/thread.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/base/thread.cpp b/lib/base/thread.cpp new file mode 100644 index 00000000..4cff9259 --- /dev/null +++ b/lib/base/thread.cpp @@ -0,0 +1,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"); +} |
