Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method · added in Ruby 4.0
Ractor#value
() -> untyped
ractor.value → obj
ractor.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/ractor.rb, line 641
def value
self.join
__builtin_ractor_value
end
Waits for ractor to complete and returns its value or raises the exception which terminated the Ractor. The termination value will be moved to the calling Ractor. Therefore, at most 1 Ractor can receive another ractor’s termination value, and it can be received only once.
Example
r = Ractor.new{ [1, 2] } r.value #=> [1, 2] (unshareable object) r.value #=> Ractor::Error Ractor.new(r){|r| r.value} #=> Ractor::Error
Ruby version changes
-
4.0
-
Ractor#joinandRactor#valuewere added to wait for the termination of aRactor. These are similar toThread#joinandThread#value.
-