module Polyphony::FiberControl
Fiber
control API
Public Instance Methods
await()
click to toggle source
# File lib/polyphony/extensions/fiber.rb, line 75 def await Fiber.await(self).first end
Also aliased as: join
cancel()
click to toggle source
# File lib/polyphony/extensions/fiber.rb, line 36 def cancel return if @running == false schedule Polyphony::Cancel.new end
error_from_raise_args(args)
click to toggle source
# File lib/polyphony/extensions/fiber.rb, line 62 def error_from_raise_args(args) case (arg = args.shift) when String then RuntimeError.new(arg) when Class then arg.new(args.shift) when Exception then arg else RuntimeError.new end end
graceful_shutdown=(graceful)
click to toggle source
# File lib/polyphony/extensions/fiber.rb, line 42 def graceful_shutdown=(graceful) @graceful_shutdown = graceful end
graceful_shutdown?()
click to toggle source
# File lib/polyphony/extensions/fiber.rb, line 46 def graceful_shutdown? @graceful_shutdown end
interject(&block)
click to toggle source
# File lib/polyphony/extensions/fiber.rb, line 71 def interject(&block) raise Polyphony::Interjection.new(block) end
interrupt(value = nil)
click to toggle source
# File lib/polyphony/extensions/fiber.rb, line 14 def interrupt(value = nil) return if @running == false schedule Polyphony::MoveOn.new(value) end
Also aliased as: stop
monitor_mailbox()
click to toggle source
# File lib/polyphony/extensions/fiber.rb, line 10 def monitor_mailbox @monitor_mailbox ||= Polyphony::Queue.new end
raise(*args)
click to toggle source
# File lib/polyphony/extensions/fiber.rb, line 57 def raise(*args) error = error_from_raise_args(args) schedule(error) end
restart(value = nil)
click to toggle source
# File lib/polyphony/extensions/fiber.rb, line 21 def restart(value = nil) raise "Can''t restart main fiber" if @main if @running schedule Polyphony::Restart.new(value) return self end fiber = parent.spin(@tag, @caller, &@block) @monitors&.each_key { |f| fiber.monitor(f) } fiber.schedule(value) unless value.nil? fiber end
Also aliased as: reset
terminate(graceful = false)
click to toggle source
# File lib/polyphony/extensions/fiber.rb, line 50 def terminate(graceful = false) return if @running == false @graceful_shutdown = graceful schedule Polyphony::Terminate.new end