instance method · added in Ruby 4.0
Ractor#monitor
[T < ::Symbol] (::Ractor::Port[T]) -> untyped
ractor.monitor(port) → self
ractor.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/ractor.rb, line 634
def monitor port
__builtin_ractor_monitor(port)
end
Registers the port as a monitoring port for this ractor. When the ractor terminates, the port receives a Symbol object.
-
:exitedis sent if the ractor terminates without an unhandled exception. -
:abortedis sent if the ractor terminates by an unhandled exception.Exampler = Ractor.new{ some_task() } r.monitor(port = Ractor::Port.new) port.receive #=> :exited and r is terminated r = Ractor.new{ raise "foo" } r.monitor(port = Ractor::Port.new) port.receive #=> :aborted and r is terminated by the RuntimeError "foo"
Ruby version changes
-
4.0
-
Ractor#monitorandRactor#unmonitorwere added as low-level interfaces used internally to implementRactor#join.
-