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); \
39 #define MONO_TRY_BLOCKING \
41 void *__try_block_cookie = mono_threads_try_prepare_blocking ();
43 #define MONO_FINISH_TRY_BLOCKING \
44 mono_threads_finish_try_blocking (__try_block_cookie); \
49 extern volatile size_t mono_threads_polling_required;
51 void mono_threads_state_poll (void);
52 void* mono_threads_prepare_blocking (void);
53 void mono_threads_finish_blocking (void* cookie);
55 void* mono_threads_reset_blocking_start (void);
56 void mono_threads_reset_blocking_end (void* cookie);
58 void* mono_threads_try_prepare_blocking (void);
59 void mono_threads_finish_try_blocking (void* cookie);
61 /* JIT specific interface */
62 extern volatile size_t mono_polling_required ;
66 #define MONO_SUSPEND_CHECK do { } while (0);
67 #define MONO_PREPARE_BLOCKING {
68 #define MONO_FINISH_BLOCKING }
69 #define MONO_PREPARE_RESET_BLOCKING {
70 #define MONO_FINISH_RESET_BLOCKING }
71 #define MONO_TRY_BLOCKING {
72 #define MONO_FINISH_TRY_BLOCKING }
74 #endif /* USE_COOP_GC */