+/*
+ * timed-thread.c: Implementation of timed thread joining
+ *
+ * Author:
+ * Dick Porter (dick@ximian.com)
+ *
+ * (C) 2002 Ximian, Inc.
+ */
+
#include <config.h>
#include <glib.h>
+#if HAVE_BOEHM_GC
+#include <gc/gc.h>
+#endif
#include <pthread.h>
#include "timed-thread.h"
-#define DEBUG
+#include "mono-mutex.h"
+
+#undef DEBUG
/*
* Implementation of timed thread joining from the P1003.1d/D14 (July 1999)
thread=(TimedThread *)specific;
- pthread_mutex_lock(&thread->join_mutex);
+ mono_mutex_lock(&thread->join_mutex);
/* Tell a joiner that we're exiting.
*/
}
pthread_cond_signal(&thread->exit_cond);
- pthread_mutex_unlock(&thread->join_mutex);
+ mono_mutex_unlock(&thread->join_mutex);
/* Call pthread_exit() to call destructors and really exit the
* thread.
pthread_once(&timed_thread_once, timed_thread_init);
pthread_setspecific(timed_thread_key, (void *)thread);
+ pthread_detach(thread->id);
_wapi_timed_thread_exit(thread->start_routine(thread->arg));
}
thread=(TimedThread *)g_new0(TimedThread, 1);
- pthread_mutex_init(&thread->join_mutex, NULL);
+ mono_mutex_init(&thread->join_mutex, NULL);
pthread_cond_init(&thread->exit_cond, NULL);
thread->start_routine = start_routine;
thread->exit_routine = exit_routine;
return(result);
}
- pthread_detach(thread->id);
return(0);
}
{
int result;
- pthread_mutex_lock(&thread->join_mutex);
+ mono_mutex_lock(&thread->join_mutex);
result=0;
/* Wait until the thread announces that it's exiting, or until
}
}
- pthread_mutex_unlock(&thread->join_mutex);
+ mono_mutex_unlock(&thread->join_mutex);
if(result == 0 && thread->exiting) {
if(exitstatus!=NULL) {
*exitstatus = thread->exitstatus;
return(result);
}
+void _wapi_timed_thread_destroy (TimedThread *thread)
+{
+ mono_mutex_destroy (&thread->join_mutex);
+ pthread_cond_destroy (&thread->exit_cond);
+
+ g_free(thread);
+}