summaryrefslogtreecommitdiff
path: root/ractor.rb
diff options
context:
space:
mode:
authorKoichi Sasada <ko1@atdot.net>2020-12-22 01:55:15 +0900
committerKoichi Sasada <ko1@atdot.net>2020-12-22 05:26:32 +0900
commit35471a948739ca13b85fe900871e081d553f68e6 (patch)
tree753724336429afca42bdfc8e30befb79548835a2 /ractor.rb
parent8f2031a06725d32f59e5ecd88ede3f96e8c5e9b1 (diff)
add Ractor#[]/#[]= for ractor local storage
This API is similar to plain old Thread#[]/Fiber#[] interface with symbol key.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3962
Diffstat (limited to 'ractor.rb')
-rw-r--r--ractor.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/ractor.rb b/ractor.rb
index c73c574bdc..d72e02b60d 100644
--- a/ractor.rb
+++ b/ractor.rb
@@ -758,4 +758,14 @@ class Ractor
}
end
end
+
+ # get a value from ractor-local storage
+ def [](sym)
+ Primitive.ractor_local_value(sym)
+ end
+
+ # set a value in ractor-local storage
+ def []=(sym, val)
+ Primitive.ractor_local_value_set(sym, val)
+ end
end