diff options
| author | Felix Domke <tmbinc@elitedvb.net> | 2003-10-17 15:35:43 +0000 |
|---|---|---|
| committer | Felix Domke <tmbinc@elitedvb.net> | 2003-10-17 15:35:43 +0000 |
| commit | fc2f5b2cd655f1391f2abda1b39e37cdec98a951 (patch) | |
| tree | 312efcea86a319de407a7c314fb981fb1c71019a /lib/base/thread.cpp | |
| download | enigma2-fc2f5b2cd655f1391f2abda1b39e37cdec98a951.tar.gz enigma2-fc2f5b2cd655f1391f2abda1b39e37cdec98a951.zip | |
Initial revision
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"); +} |
