2002-05-14 Tim Coleman
[mono.git] / mono / io-layer / timed-thread.c
index 537a609aa4e48cd32e997e8c45712f1c947257af..f955607614fc698c8f5dd5a46d5d85fbe8718b52 100644 (file)
@@ -1,3 +1,12 @@
+/*
+ * 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
@@ -73,6 +82,7 @@ static void *timed_thread_start_routine(gpointer args)
        
        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));
 }
 
@@ -107,7 +117,6 @@ int _wapi_timed_thread_create(TimedThread **threadp,
                return(result);
        }
        
-       pthread_detach(thread->id);
        return(0);
 }
 
@@ -142,3 +151,10 @@ int _wapi_timed_thread_join(TimedThread *thread, struct timespec *timeout,
        return(result);
 }
 
+void _wapi_timed_thread_destroy (TimedThread *thread)
+{
+       mono_mutex_destroy (&thread->join_mutex);
+       pthread_cond_destroy (&thread->exit_cond);
+       
+       g_free(thread);
+}