We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents aff0d7d + 121e43c commit ad2e348Copy full SHA for ad2e348
core/ractor.rbs
@@ -588,6 +588,23 @@ class Ractor
588
#
589
def self.shareable?: (untyped obj) -> bool
590
591
+ # <!--
592
+ # rdoc-file=ractor.rb
593
+ # - Ractor.store_if_absent(key){ init_block }
594
+ # -->
595
+ # If the correponding value is not set, yield a value with init_block and store
596
+ # the value in thread-safe manner. This method returns corresponding stored
597
+ # value.
598
+ #
599
+ # (1..10).map{
600
+ # Thread.new(it){|i|
601
+ # Ractor.store_if_absent(:s){ f(); i }
602
+ # #=> return stored value of key :s
603
+ # }
604
+ # }.map(&:value).uniq.size #=> 1 and f() is called only once
605
606
+ def self.store_if_absent: (Symbol) { () -> untyped } -> untyped
607
+
608
# <!--
609
# rdoc-file=ractor.rb
610
# - Ractor.yield(msg, move: false) -> nil
0 commit comments