}
thread->state |= ThreadState_SuspendRequested;
- if (mono_threads_is_coop_enabled ())
- mono_os_event_reset (thread->suspended);
+ mono_os_event_reset (thread->suspended);
if (thread == mono_thread_internal_current ()) {
/* calls UNLOCK_THREAD (thread) */
{
if ((thread->state & ThreadState_SuspendRequested) != 0) {
// MOSTLY_ASYNC_SAFE_PRINTF ("RESUME (1) thread %p\n", thread_get_tid (thread));
- if (mono_threads_is_coop_enabled ())
- mono_os_event_set (thread->suspended);
thread->state &= ~ThreadState_SuspendRequested;
+ mono_os_event_set (thread->suspended);
return TRUE;
}
// MOSTLY_ASYNC_SAFE_PRINTF ("RESUME (3) thread %p\n", thread_get_tid (thread));
- if (mono_threads_is_coop_enabled ()) {
- mono_os_event_set (thread->suspended);
- } else {
+ mono_os_event_set (thread->suspended);
+
+ if (!thread->self_suspended) {
UNLOCK_THREAD (thread);
/* Awake the thread */
thread->state &= ~ThreadState_AbortRequested;
thread->state |= ThreadState_SuspendRequested;
- if (mono_threads_is_coop_enabled ())
- mono_os_event_reset (thread->suspended);
+ mono_os_event_reset (thread->suspended);
/* Signal the thread to suspend + calls UNLOCK_THREAD (thread) */
async_suspend_internal (thread, TRUE);
// MOSTLY_ASYNC_SAFE_PRINTF ("ASYNC SUSPEND thread %p\n", thread_get_tid (thread));
+ thread->self_suspended = FALSE;
+
data.thread = thread;
data.interrupt = interrupt;
data.interrupt_token = NULL;
self_suspend_internal (void)
{
MonoInternalThread *thread;
+ MonoOSEvent *event;
+ MonoOSEventWaitRet res;
thread = mono_thread_internal_current ();
// MOSTLY_ASYNC_SAFE_PRINTF ("SELF SUSPEND thread %p\n", thread_get_tid (thread));
- if (!mono_threads_is_coop_enabled ())
- mono_thread_info_begin_self_suspend ();
+ thread->self_suspended = TRUE;
thread->state &= ~ThreadState_SuspendRequested;
thread->state |= ThreadState_Suspended;
UNLOCK_THREAD (thread);
- if (!mono_threads_is_coop_enabled ())
- mono_thread_info_end_self_suspend ();
- else {
- MonoOSEvent *event;
- MonoOSEventWaitRet res;
-
- event = thread->suspended;
+ event = thread->suspended;
- MONO_ENTER_GC_SAFE;
- res = mono_os_event_wait_one (event, MONO_INFINITE_WAIT);
- g_assert (res == MONO_OS_EVENT_WAIT_RET_SUCCESS_0 || res == MONO_OS_EVENT_WAIT_RET_ALERTED);
- MONO_EXIT_GC_SAFE;
- }
+ MONO_ENTER_GC_SAFE;
+ res = mono_os_event_wait_one (event, MONO_INFINITE_WAIT);
+ g_assert (res == MONO_OS_EVENT_WAIT_RET_SUCCESS_0 || res == MONO_OS_EVENT_WAIT_RET_ALERTED);
+ MONO_EXIT_GC_SAFE;
}
/*