Ractor.[] and Ractor.[]=

`Ractor#[]/[]=` is only for accessors to the current ractor, so that
`Ractor.[]/[]=` is simpler.
[Feature #20715]
This commit is contained in:
Koichi Sasada 2024-11-05 04:43:24 +09:00
parent f0d0c030c0
commit 075a102c93
Notes: git 2024-11-08 09:03:09 +00:00

View File

@ -834,16 +834,26 @@ class Ractor
end
end
# get a value from ractor-local storage
# get a value from ractor-local storage of current Ractor
def [](sym)
Primitive.ractor_local_value(sym)
end
# set a value in ractor-local storage
# set a value in ractor-local storage of current Ractor
def []=(sym, val)
Primitive.ractor_local_value_set(sym, val)
end
# get a value from ractor-local storage of current Ractor
def self.[](sym)
Primitive.ractor_local_value(sym)
end
# set a value in ractor-local storage of current Ractor
def self.[]=(sym, val)
Primitive.ractor_local_value_set(sym, val)
end
# returns main ractor
def self.main
__builtin_cexpr! %q{