--- a/src/thread_pthread.cpp Tue Apr 01 13:45:04 2008 +0000
+++ b/src/thread_pthread.cpp Wed Apr 02 10:55:28 2008 +0000
@@ -117,6 +117,26 @@
return false;
}
+ /* virtual */ bool Exit()
+ {
+ /* You can only exit yourself */
+ assert(IsCurrent());
+ /* If the thread is not running, we are already closed */
+ if (!IsRunning()) return false;
+
+ /* For now we terminate by throwing an error, gives much cleaner cleanup */
+ throw 0;
+ }
+
+ /* virtual */ void Join()
+ {
+ /* You cannot join yourself */
+ assert(!IsCurrent());
+
+ pthread_join(m_thr, NULL);
+ m_thr = 0;
+ }
+
/* virtual */ bool IsCurrent()
{
return pthread_self() == m_thr;
@@ -134,7 +154,7 @@
*/
static void *stThreadProc(void *thr)
{
- return ((ThreadObject_pthread*)thr)->ThreadProc();
+ return ((ThreadObject_pthread *)thr)->ThreadProc();
}
/**
@@ -150,13 +170,11 @@
try {
m_proc(m_param);
} catch (...) {
- DEBUG(misc, 0, "Exception in thread %u!", GetId());
}
- /* The thread died, so we are no longer valid */
- m_thr = 0;
/* Notify threads waiting for our completion */
sem_post(&m_sem_stop);
+
return NULL;
}
};