summaryrefslogtreecommitdiff
path: root/ractor.c
diff options
context:
space:
mode:
authorKoichi Sasada <ko1@atdot.net>2020-11-30 16:18:43 +0900
committerKoichi Sasada <ko1@atdot.net>2020-12-01 15:44:18 +0900
commit182fb73c40351f917bf44626c44c1adb6cb1aa5a (patch)
treefe9dd0b8c312dc491b1576004ce80122b77fbfe4 /ractor.c
parent8247b8eddeb2a504a5c9776d1f77d413c8146897 (diff)
rb_ext_ractor_safe() to declare ractor-safe ext
C extensions can violate the ractor-safety, so only ractor-safe C extensions (C methods) can run on non-main ractors. rb_ext_ractor_safe(true) declares that the successive defined methods are ractor-safe. Otherwiwze, defined methods checked they are invoked in main ractor and raise an error if invoked at non-main ractors. [Feature #17307]
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3824
Diffstat (limited to 'ractor.c')
-rw-r--r--ractor.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/ractor.c b/ractor.c
index 693bbe274d..c895aab980 100644
--- a/ractor.c
+++ b/ractor.c
@@ -21,6 +21,7 @@ static VALUE rb_eRactorRemoteError;
static VALUE rb_eRactorMovedError;
static VALUE rb_eRactorClosedError;
static VALUE rb_cRactorMovedObject;
+VALUE rb_eRactorUnsafeError;
VALUE
rb_ractor_error_class(void)
@@ -1670,6 +1671,7 @@ Init_Ractor(void)
rb_eRactorRemoteError = rb_define_class_under(rb_cRactor, "RemoteError", rb_eRactorError);
rb_eRactorMovedError = rb_define_class_under(rb_cRactor, "MovedError", rb_eRactorError);
rb_eRactorClosedError = rb_define_class_under(rb_cRactor, "ClosedError", rb_eStopIteration);
+ rb_eRactorUnsafeError = rb_define_class_under(rb_cRactor, "UnsafeError", rb_eRactorError);
rb_cRactorMovedObject = rb_define_class_under(rb_cRactor, "MovedObject", rb_cBasicObject);
rb_undef_alloc_func(rb_cRactorMovedObject);