instance method · added in Ruby 4.0
Ractor#join
() -> self
ractor.join → self
ractor.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/ractor.rb, line 585
def join
port = Port.new
self.monitor port
if port.receive == :aborted
__builtin_ractor_value
end
self
ensure
port.close
end
Waits for the termination of the Ractor. If the Ractor was aborted (terminated by an unhandled exception), the exception is raised in the current ractor.
Example
Ractor.new{}.join #=> ractor Ractor.new{ raise "foo" }.join #=> raises the exception "foo (RuntimeError)"
Ruby version changes
-
4.0
-
Ractor#joinandRactor#valuewere added to wait for the termination of aRactor. These are similar toThread#joinandThread#value. -
Ractor#monitorandRactor#unmonitorwere added as low-level interfaces used internally to implementRactor#join.
-