digital-fabric / polyphony

Fine-grained concurrency for Ruby
https://www.rubydoc.info/gems/polyphony
MIT License
655 stars 17 forks source link

Fiber#supervise with watcher #94

Closed floriandejonckheere closed 1 year ago

floriandejonckheere commented 1 year ago

According to the documentation, it's possible to set up a watcher when supervising child fibers. However, I found that the supervision code ignores the watcher: argument. Was this functionality removed? The documentation also doesn't mention on_done: and on_error:.

noteflakes commented 1 year ago

The documentation is not up to date. The current implementation does not allow setting a watcher. You can instead monitor a fiber manually by calling Fiber#monitor, e.g.:

f = spin { sleep 1 }
f.monitor(Fiber.current)
msg = Fiber.current.monitor_mailbox.shift