From 5d97bdc2dcb835c877010daa033cc2b1dfeb86d6 Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Fri, 30 Oct 2020 00:32:53 +0900 Subject: Ractor.make_shareable(a_proc) Ractor.make_shareable() supports Proc object if (1) a Proc only read outer local variables (no assignments) (2) read outer local variables are shareable. Read local variables are stored in a snapshot, so after making shareable Proc, any assignments are not affeect like that: ```ruby a = 1 pr = Ractor.make_shareable(Proc.new{p a}) pr.call #=> 1 a = 2 pr.call #=> 1 # `a = 2` doesn't affect ``` [Feature #17284] --- vm_core.h | 1 + 1 file changed, 1 insertion(+) (limited to 'vm_core.h') diff --git a/vm_core.h b/vm_core.h index c4341b474c..9ef3af515c 100644 --- a/vm_core.h +++ b/vm_core.h @@ -1065,6 +1065,7 @@ typedef struct { VALUE rb_proc_isolate(VALUE self); VALUE rb_proc_isolate_bang(VALUE self); +VALUE rb_proc_ractor_make_shareable(VALUE self); typedef struct { VALUE flags; /* imemo header */ -- cgit v1.2.3