2002-08-21 Miguel de Icaza <miguel@ximian.com>
[mono.git] / mono / metadata / threads-types.h
index 307777daca29763c0a722c810652602769faee0b..6e93857ae14c8f80c86ca8bd30aaa2e9e01ae82e 100644 (file)
 #ifndef _MONO_METADATA_THREADS_TYPES_H_
 #define _MONO_METADATA_THREADS_TYPES_H_
 
-#include <config.h>
 
-#ifdef HAVE_PTHREAD
-#include <mono/metadata/threads-pthread-types.h>
-#else
-#warning "No thread support found!"
-#include <mono/metadata/threads-dummy-types.h>
-#endif
+#include <mono/io-layer/io-layer.h>
 
-extern void mono_threads_synchronisation_init(MonoThreadsSync *);
-extern void mono_threads_synchronisation_free(MonoThreadsSync *);
+/*
+ * This is bonkers. We are emulating condition variables here using
+ * win32 calls, which on Linux are being emulated with condition
+ * variables :-)
+ *
+ * See http://www.cs.wustl.edu/~schmidt/win32-cv-1.html for the design.
+ */
+
+typedef struct 
+{
+       HANDLE monitor;
+       guint32 tid;
+
+       /* Need to count how many times this monitor object has been
+        * locked by the owning thread, so that we can unlock it
+        * completely in Wait()
+        */
+       guint32 count;
+
+       /* condition variable management */
+       guint32 waiters_count;
+       CRITICAL_SECTION waiters_count_lock;
+       HANDLE sema;
+       HANDLE waiters_done;
+       gboolean was_broadcast;
+} MonoThreadsSync;
 
 #endif /* _MONO_METADATA_THREADS_TYPES_H_ */