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__
17 /* Runtime consumable API */
19 #define MONO_SUSPEND_CHECK() do { \
20 if (G_UNLIKELY (mono_threads_polling_required)) mono_threads_state_poll (); \
23 #define MONO_PREPARE_BLOCKING \
25 void *__blocking_cookie = mono_threads_prepare_blocking ();
27 #define MONO_FINISH_BLOCKING \
28 mono_threads_finish_blocking (__blocking_cookie); \
31 #define MONO_PREPARE_RESET_BLOCKING \
33 void *__reset_cookie = mono_threads_reset_blocking_start ();
35 #define MONO_FINISH_RESET_BLOCKING \
36 mono_threads_reset_blocking_end (__reset_cookie); \
40 extern volatile size_t mono_threads_polling_required;
42 void mono_threads_state_poll (void);
43 void* mono_threads_prepare_blocking (void);
44 void mono_threads_finish_blocking (void* cookie);
46 void* mono_threads_reset_blocking_start (void);
47 void mono_threads_reset_blocking_end (void* cookie);
51 #define MONO_SUSPEND_CHECK do { } while (0);
52 #define MONO_PREPARE_BLOCKING {
53 #define MONO_FINISH_BLOCKING }
54 #define MONO_PREPARE_RESET_BLOCKING {
55 #define MONO_FINISH_RESET_BLOCKING }
57 #endif /* USE_COOP_GC */