Page MenuHomePhabricator (Chris)

No OneTemporary

Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
diff --git a/util/thread.cpp b/util/thread.cpp
index 552fbe76..8ab6711b 100644
--- a/util/thread.cpp
+++ b/util/thread.cpp
@@ -1,72 +1,77 @@
#include <pthread.h>
#include "thread.h"
namespace Util{
Thread::Thread():
done(false){
pthread_mutex_init(&doneLock, NULL);
}
Thread::Thread(void * (*thread)(void*), void * arg){
pthread_mutex_init(&doneLock, NULL);
start(thread, arg);
}
static void * do_thread(void * arg){
Thread * thread = (Thread *) arg;
thread->doRun();
return NULL;
}
void Thread::doRun(){
this->function(this->arg);
pthread_mutex_lock(&doneLock);
this->done = true;
pthread_mutex_unlock(&doneLock);
}
void Thread::start(void * (*thread)(void *), void * arg){
done = false;
this->arg = arg;
this->function = thread;
pthread_create(&this->thread, NULL, do_thread, this);
}
bool Thread::isRunning(){
pthread_mutex_lock(&doneLock);
bool what = done;
pthread_mutex_unlock(&doneLock);
return what;
}
void Thread::kill(){
+ /* FIXME: cancel is not implemented for libogc, find another way.
+ * thread suspend/resume is there, though.
+ */
+#if !defined(WII)
pthread_cancel(thread);
+#endif
pthread_join(thread, NULL);
}
Thread::~Thread(){
/* FIXME: Should we join the thread? */
/* pthread_join(thread); */
}
ThreadBoolean::ThreadBoolean(volatile bool & what, pthread_mutex_t & lock):
what(what),
lock(lock){
}
bool ThreadBoolean::get(){
pthread_mutex_lock(&lock);
bool b = what;
pthread_mutex_unlock(&lock);
return b;
}
void ThreadBoolean::set(bool value){
pthread_mutex_lock(&lock);
what = value;
pthread_mutex_unlock(&lock);
}
}

File Metadata

Mime Type
text/x-diff
Expires
Thu, Jun 11, 12:37 PM (3 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
69066
Default Alt Text
(1 KB)

Event Timeline