summaryrefslogtreecommitdiff
path: root/ractor.c
diff options
context:
space:
mode:
authorYusuke Endoh <mame@ruby-lang.org>2022-03-24 14:14:07 +0900
committerYusuke Endoh <mame@ruby-lang.org>2022-03-30 16:50:46 +0900
commit23530d68cb04aed9c2f59a050523b0193ee2d0c1 (patch)
treed56d750e74bed919b4099f880e06f759eb451015 /ractor.c
parenta94002115beaf989aec4c9b2a746ac8d19440e57 (diff)
ractor.c: Add a helper function to ensure the context is a main ractor
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/5703
Diffstat (limited to 'ractor.c')
-rw-r--r--ractor.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/ractor.c b/ractor.c
index f010574028..0c17d575ee 100644
--- a/ractor.c
+++ b/ractor.c
@@ -2531,6 +2531,14 @@ rb_ractor_ensure_shareable(VALUE obj, VALUE name)
return obj;
}
+void
+rb_ractor_ensure_main_ractor(const char *msg)
+{
+ if (!rb_ractor_main_p()) {
+ rb_raise(rb_eRactorIsolationError, "%s", msg);
+ }
+}
+
static enum obj_traverse_iterator_result
shareable_p_enter(VALUE obj)
{