summaryrefslogtreecommitdiff
path: root/bootstraptest
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 /bootstraptest
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 'bootstraptest')
-rw-r--r--bootstraptest/test_ractor.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/bootstraptest/test_ractor.rb b/bootstraptest/test_ractor.rb
index a853e91416..06bd739931 100644
--- a/bootstraptest/test_ractor.rb
+++ b/bootstraptest/test_ractor.rb
@@ -1245,6 +1245,20 @@ assert_equal '[:ok, :ok]', %q{
end
}
+# Ractor-local storage
+assert_equal '[nil, "b", "a"]', %q{
+ ans = []
+ Ractor.current[:key] = 'a'
+ r = Ractor.new{
+ Ractor.yield self[:key]
+ self[:key] = 'b'
+ self[:key]
+ }
+ ans << r.take
+ ans << r.take
+ ans << Ractor.current[:key]
+}
+
###
### Synchronization tests
###