summaryrefslogtreecommitdiff
path: root/ractor.c
diff options
context:
space:
mode:
authorKoichi Sasada <ko1@atdot.net>2020-12-19 05:52:18 +0900
committerKoichi Sasada <ko1@atdot.net>2020-12-19 05:52:18 +0900
commit80cb9165fa34185b601970da407a295a78ec9eff (patch)
treef19d3490ffb3fb4f5e68d02c0f551cf9d8fcbcc4 /ractor.c
parentcee02d754d76563635c1db90d2ab6c01f8492470 (diff)
add "copy: true" option for Ractor.make_shareable
Ractor.make_shareable(obj) tries to make obj a shareable object by changing the attribute of obj and traversable objects from obj (mainly freeze them). "copy: true" option is more conservative approach by make deep copied object and make it sharable. It doesn't affect any existing objects.
Diffstat (limited to 'ractor.c')
-rw-r--r--ractor.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/ractor.c b/ractor.c
index 89b4f68afb..0d850aebba 100644
--- a/ractor.c
+++ b/ractor.c
@@ -2347,6 +2347,16 @@ rb_ractor_make_shareable(VALUE obj)
return obj;
}
+VALUE
+rb_ractor_make_copy_shareable(VALUE obj)
+{
+ VALUE copy = ractor_copy(obj);
+ rb_obj_traverse(copy,
+ make_shareable_check_shareable,
+ null_leave, mark_shareable);
+ return copy;
+}
+
static enum obj_traverse_iterator_result
shareable_p_enter(VALUE obj)
{