#include <mono/metadata/marshal.h>
#include <mono/metadata/profiler-private.h>
#include <mono/utils/mono-time.h>
-#include <mono/utils/mono-semaphore.h>
/*
* Pull the list of opcodes
gint32 hash_code;
#endif
volatile gint32 entry_count;
- MonoSemType *entry_sem;
+ HANDLE entry_sem;
GSList *wait_list;
void *data;
};
LOCK_DEBUG (g_message ("%s: Finalizing sync %p", __func__, mon));
if (mon->entry_sem != NULL) {
- MONO_SEM_DESTROY (mon->entry_sem);
- g_free (mon->entry_sem);
+ CloseHandle (mon->entry_sem);
mon->entry_sem = NULL;
}
/* If this isn't empty then something is seriously broken - it
{
MonoThreadsSync *mon;
gsize id = GetCurrentThreadId ();
- MonoSemType *sem;
+ HANDLE sem;
guint32 then = 0, now, delta;
guint32 waitms;
guint32 ret;
*/
if (mon->entry_sem == NULL) {
/* Create the semaphore */
- sem = g_new0 (MonoSemType, 1);
- MONO_SEM_INIT (sem, 0);
+ sem = CreateSemaphore (NULL, 0, 0x7fffffff, NULL);
g_assert (sem != NULL);
if (InterlockedCompareExchangePointer ((gpointer*)&mon->entry_sem, sem, NULL) != NULL) {
/* Someone else just put a handle here */
- MONO_SEM_DESTROY (sem);
- g_free (sem);
+ CloseHandle (sem);
}
}
* We pass TRUE instead of allow_interruption since we have to check for the
* StopRequested case below.
*/
- ret = MONO_SEM_TIMEDWAIT_ALERTABLE(mon->entry_sem, waitms, TRUE);
+ ret = WaitForSingleObjectEx (mon->entry_sem, waitms, TRUE);
mono_thread_clr_state (thread, ThreadState_WaitSleepJoin);
* struct.
*/
if (mon->entry_count > 0) {
- MONO_SEM_POST (mon->entry_sem);
+ ReleaseSemaphore (mon->entry_sem, 1, NULL);
}
} else {
LOCK_DEBUG (g_message ("%s: (%d) Object %p is now locked %d times", __func__, GetCurrentThreadId (), obj, nest));