Skip to content

Commit 075a102

Browse files
committed
Ractor.[] and Ractor.[]=
`Ractor#[]/[]=` is only for accessors to the current ractor, so that `Ractor.[]/[]=` is simpler. [Feature #20715]
1 parent f0d0c03 commit 075a102

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

ractor.rb

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -834,16 +834,26 @@ def self.make_shareable obj, copy: false
834834
end
835835
end
836836

837-
# get a value from ractor-local storage
837+
# get a value from ractor-local storage of current Ractor
838838
def [](sym)
839839
Primitive.ractor_local_value(sym)
840840
end
841841

842-
# set a value in ractor-local storage
842+
# set a value in ractor-local storage of current Ractor
843843
def []=(sym, val)
844844
Primitive.ractor_local_value_set(sym, val)
845845
end
846846

847+
# get a value from ractor-local storage of current Ractor
848+
def self.[](sym)
849+
Primitive.ractor_local_value(sym)
850+
end
851+
852+
# set a value in ractor-local storage of current Ractor
853+
def self.[]=(sym, val)
854+
Primitive.ractor_local_value_set(sym, val)
855+
end
856+
847857
# returns main ractor
848858
def self.main
849859
__builtin_cexpr! %q{

0 commit comments

Comments
 (0)