summaryrefslogtreecommitdiffstats
path: root/branches/lydia/thread.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'branches/lydia/thread.cpp')
-rw-r--r--branches/lydia/thread.cpp46
1 files changed, 0 insertions, 46 deletions
diff --git a/branches/lydia/thread.cpp b/branches/lydia/thread.cpp
deleted file mode 100644
index fa1c0ef..0000000
--- a/branches/lydia/thread.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-
-#include <thread.h>
-#include <utils.h>
-
-static void *kickoff(void *arg) {
- ((Thread*)arg)->run();
- return NULL;
-}
-
-Thread::Thread() {
- if(pthread_mutex_init(&mutex,NULL) == -1)
- E("error initializing thread mutex");
- if(pthread_attr_init(&attr) == -1)
- E("error initializing thread attribute");
-
- pthread_attr_setdetachstate(&attr,PTHREAD_CREATE_JOINABLE);
-
- running = false;
- quit = false;
-}
-
-Thread::~Thread() {
- if(pthread_mutex_destroy(&mutex) == -1)
- E("error destroying thread mutex");
- if(pthread_attr_destroy(&attr) == -1)
- E("error destroying thread attribute");
-}
-
-bool Thread::launch() {
- lock(); // the runner will unlock when ready
- return pthread_create(&thread,&attr,&kickoff, this);
- lock(); // wait until the thread is ready
- unlock();
-}
-
-void Thread::lock() {
- pthread_mutex_lock(&mutex);
-}
-
-void Thread::unlock() {
- pthread_mutex_unlock(&mutex);
-}
-
-void Thread::join() {
- pthread_join(thread,NULL);
-}