2 * mono-threads-coop.h: Cooperative suspend thread helpers
5 * Rodrigo Kumpera (kumpera@gmail.com)
10 #ifndef __MONO_THREADS_COOP_H__
11 #define __MONO_THREADS_COOP_H__
16 #include "checked-build.h"
20 /* JIT specific interface */
21 extern volatile size_t mono_polling_required;
23 /* Runtime consumable API */
25 static gboolean G_GNUC_UNUSED
26 mono_threads_is_coop_enabled (void)
28 #if defined(USE_COOP_GC)
31 static gboolean is_coop_enabled = -1;
32 if (G_UNLIKELY (is_coop_enabled == -1))
33 is_coop_enabled = g_getenv ("MONO_ENABLE_COOP") != NULL ? TRUE : FALSE;
34 return is_coop_enabled;
41 mono_threads_state_poll (void);
44 mono_threads_prepare_blocking (gpointer stackdata);
47 mono_threads_finish_blocking (gpointer cookie, gpointer stackdata);
50 mono_threads_reset_blocking_start (gpointer stackdata);
53 mono_threads_reset_blocking_end (gpointer cookie, gpointer stackdata);
56 mono_threads_safepoint (void)
58 if (G_UNLIKELY (mono_polling_required))
59 mono_threads_state_poll ();
62 #define MONO_PREPARE_BLOCKING \
63 MONO_REQ_GC_NOT_CRITICAL; \
66 gpointer __blocking_cookie = mono_threads_prepare_blocking (&__dummy)
68 #define MONO_FINISH_BLOCKING \
69 mono_threads_finish_blocking (__blocking_cookie, &__dummy); \
72 #define MONO_PREPARE_RESET_BLOCKING \
75 gpointer __reset_cookie = mono_threads_reset_blocking_start (&__dummy)
77 #define MONO_FINISH_RESET_BLOCKING \
78 mono_threads_reset_blocking_end (__reset_cookie, &__dummy); \