lib/polyphony/core/supervisor.rb in polyphony-0.21 vs lib/polyphony/core/supervisor.rb in polyphony-0.22
- old
+ new
@@ -14,11 +14,11 @@
def await(&block)
@supervisor_fiber = Fiber.current
block&.(self)
suspend
- @coprocesses.map { |cp| cp.result }
+ @coprocesses.map(&:result)
rescue Exceptions::MoveOn => e
e.value
ensure
finalize_await
end
@@ -73,12 +73,13 @@
@pending.delete(coprocess)
@supervisor_fiber&.transfer if @pending.empty?
end
end
+# Extension for Coprocess class
class Coprocess
def self.await(*coprocs)
supervise do |s|
coprocs.each { |cp| s.add cp }
end
end
-end
\ No newline at end of file
+end