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__
18 /* JIT specific interface */
19 extern volatile size_t mono_polling_required;
21 /* Runtime consumable API */
23 static gboolean G_GNUC_UNUSED
24 mono_threads_is_coop_enabled (void)
26 #if defined(USE_COOP_GC)
29 static gboolean is_coop_enabled = -1;
30 if (G_UNLIKELY (is_coop_enabled == -1))
31 is_coop_enabled = g_getenv ("MONO_ENABLE_COOP") != NULL ? TRUE : FALSE;
32 return is_coop_enabled;
39 mono_threads_state_poll (void);
42 mono_threads_prepare_blocking (gpointer stackdata);
45 mono_threads_finish_blocking (gpointer cookie, gpointer stackdata);
48 mono_threads_reset_blocking_start (gpointer stackdata);
51 mono_threads_reset_blocking_end (gpointer cookie, gpointer stackdata);
54 mono_threads_safepoint (void)
56 if (G_UNLIKELY (mono_polling_required))
57 mono_threads_state_poll ();
60 #define MONO_PREPARE_BLOCKING \
63 gpointer __blocking_cookie = mono_threads_prepare_blocking (&__dummy)
65 #define MONO_FINISH_BLOCKING \
66 mono_threads_finish_blocking (__blocking_cookie, &__dummy); \
69 #define MONO_PREPARE_RESET_BLOCKING \
72 gpointer __reset_cookie = mono_threads_reset_blocking_start (&__dummy)
74 #define MONO_FINISH_RESET_BLOCKING \
75 mono_threads_reset_blocking_end (__reset_cookie, &__dummy); \