aboutsummaryrefslogtreecommitdiff
path: root/lib/base/thread.cpp
diff options
context:
space:
mode:
authorFelix Domke <tmbinc@elitedvb.net>2003-10-17 15:35:43 +0000
committerFelix Domke <tmbinc@elitedvb.net>2003-10-17 15:35:43 +0000
commitfc2f5b2cd655f1391f2abda1b39e37cdec98a951 (patch)
tree312efcea86a319de407a7c314fb981fb1c71019a /lib/base/thread.cpp
downloadenigma2-fc2f5b2cd655f1391f2abda1b39e37cdec98a951.tar.gz
enigma2-fc2f5b2cd655f1391f2abda1b39e37cdec98a951.zip
Initial revision
Diffstat (limited to 'lib/base/thread.cpp')
-rw-r--r--lib/base/thread.cpp34
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");
+}