mono_raise_exception ((MonoException*)exc);
}
+static guint32
+guarded_wait (HANDLE handle, guint32 timeout, gboolean alertable)
+{
+ guint32 result;
+
+ MONO_PREPARE_BLOCKING
+ result = WaitForSingleObjectEx (handle, timeout, alertable);
+ MONO_FINISH_BLOCKING
+
+ return result;
+}
+
/*
* mono_domain_unload:
* @domain: The domain to unload
g_free (name);
/* Wait for the thread */
- while (!thread_data->done && WaitForSingleObjectEx (thread_handle, INFINITE, TRUE) == WAIT_IO_COMPLETION) {
+ while (!thread_data->done && guarded_wait (thread_handle, INFINITE, TRUE) == WAIT_IO_COMPLETION) {
if (mono_thread_internal_has_appdomain_ref (mono_thread_internal_current (), domain) && (mono_thread_interruption_requested ())) {
/* The unload thread tries to abort us */
/* The icall wrapper will execute the abort */
GCStats gc_stats;
+static guint32
+guarded_wait (HANDLE handle, guint32 timeout, gboolean alertable)
+{
+ guint32 result;
+
+ MONO_PREPARE_BLOCKING
+ result = WaitForSingleObjectEx (handle, timeout, alertable);
+ MONO_FINISH_BLOCKING
+
+ return result;
+}
+
static void
add_thread_to_finalize (MonoInternalThread *thread)
{
timeout = INFINITE;
while (TRUE) {
- res = WaitForSingleObjectEx (done_event, timeout, TRUE);
+ res = guarded_wait (done_event, timeout, TRUE);
/* printf ("WAIT RES: %d.\n", res); */
if (res == WAIT_IO_COMPLETION) {
ResetEvent (pending_done_event);
mono_gc_finalize_notify ();
/* g_print ("Waiting for pending finalizers....\n"); */
- WaitForSingleObjectEx (pending_done_event, INFINITE, TRUE);
+ guarded_wait (pending_done_event, INFINITE, TRUE);
/* g_print ("Done pending....\n"); */
#endif
}
mono_gc_finalize_notify ();
/* Finishing the finalizer thread, so wait a little bit... */
/* MS seems to wait for about 2 seconds */
- if (WaitForSingleObjectEx (shutdown_event, 2000, FALSE) == WAIT_TIMEOUT) {
+ if (guarded_wait (shutdown_event, 2000, FALSE) == WAIT_TIMEOUT) {
int ret;
/* Set a flag which the finalizer thread can check */
mono_thread_internal_stop (gc_thread);
/* Wait for it to stop */
- ret = WaitForSingleObjectEx (gc_thread->handle, 100, TRUE);
+ ret = guarded_wait (gc_thread->handle, 100, TRUE);
if (ret == WAIT_TIMEOUT) {
/*
int ret;
/* Wait for the thread to actually exit */
- ret = WaitForSingleObjectEx (gc_thread->handle, INFINITE, TRUE);
+ ret = guarded_wait (gc_thread->handle, INFINITE, TRUE);
g_assert (ret == WAIT_OBJECT_0);
mono_thread_join (GUINT_TO_POINTER (gc_thread->tid));
/* Poll the event again, just in case it was signalled
* while we were trying to regain the monitor lock
*/
+ MONO_PREPARE_BLOCKING
ret = WaitForSingleObjectEx (event, 0, FALSE);
+ MONO_FINISH_BLOCKING
}
/* Pulse will have popped our event from the queue if it signalled
{
guint32 ret;
+ MONO_PREPARE_BLOCKING
if(ms<0) {
/* Wait forever */
ret=WaitForSingleObjectEx (process, INFINITE, TRUE);
} else {
ret=WaitForSingleObjectEx (process, ms, TRUE);
}
+ MONO_FINISH_BLOCKING
+
if(ret==WAIT_OBJECT_0) {
return(TRUE);
} else {
MONO_OBJECT_SETREF (ares, handle, (MonoObject*) mono_wait_handle_new (mono_object_domain (ares), wait_event));
}
mono_monitor_exit ((MonoObject*) ares);
+ MONO_PREPARE_BLOCKING
WaitForSingleObjectEx (wait_event, INFINITE, TRUE);
+ MONO_FINISH_BLOCKING
}
ac = (MonoAsyncCall*) ares->object_data;
mono_memory_write_barrier ();
while (domain->threadpool_jobs) {
+ MONO_PREPARE_BLOCKING
WaitForSingleObject (sem, timeout);
+ MONO_FINISH_BLOCKING
if (timeout != -1) {
timeout -= mono_msec_ticks () - start;
if (timeout <= 0) {
wait_event = mono_wait_handle_get_handle ((MonoWaitHandle *) ares->handle);
}
mono_monitor_exit ((MonoObject *) ares);
+ MONO_PREPARE_BLOCKING
WaitForSingleObjectEx (wait_event, INFINITE, TRUE);
+ MONO_FINISH_BLOCKING
} else {
mono_monitor_exit ((MonoObject *) ares);
}
if (domain->threadpool_jobs && timeout != -1)
start_time = mono_msec_ticks ();
while (domain->threadpool_jobs) {
+ MONO_PREPARE_BLOCKING
WaitForSingleObject (sem_handle, timeout);
+ MONO_FINISH_BLOCKING
if (timeout != -1 && (mono_msec_ticks () - start_time) > timeout) {
result = FALSE;
break;
THREAD_DEBUG (g_message("%s: %d threads to wait for in this batch", __func__, wait->num));
+ MONO_PREPARE_BLOCKING
ret=WaitForMultipleObjectsEx(wait->num, wait->handles, TRUE, timeout, TRUE);
+ MONO_FINISH_BLOCKING
if(ret==WAIT_FAILED) {
/* See the comment in build_wait_tids() */
count++;
}
+ MONO_PREPARE_BLOCKING
ret=WaitForMultipleObjectsEx (count, wait->handles, FALSE, timeout, TRUE);
+ MONO_FINISH_BLOCKING
if(ret==WAIT_FAILED) {
/* See the comment in build_wait_tids() */
/*Only wait on the suspend event if we are using the old path */
if (eventidx > 0 && !mono_thread_info_new_interrupt_enabled ()) {
+ MONO_PREPARE_BLOCKING
WaitForMultipleObjectsEx (eventidx, events, TRUE, 100, FALSE);
+ MONO_FINISH_BLOCKING
+
for (i = 0; i < wait->num; ++i) {
MonoInternalThread *thread = wait->threads [i];
for (;;)
Sleep (1000);
}
-
+
+ MONO_PREPARE_BLOCKING
WaitForSingleObject (thread->suspend_event, INFINITE);
+ MONO_FINISH_BLOCKING
LOCK_THREAD (thread);
UNLOCK_THREAD (thread);
/* Wait for the thread to awake */
+ MONO_PREPARE_BLOCKING
WaitForSingleObject (thread->resume_event, INFINITE);
+ MONO_FINISH_BLOCKING
+
CloseHandle (thread->resume_event);
thread->resume_event = NULL;
return TRUE;