snivilised / lorax

🌟 reactive extensions for go (a pseudo rxgo version 3)
MIT License
4 stars 0 forks source link

timeout on send #281

Closed plastikfan closed 3 months ago

plastikfan commented 3 months ago

The correct way to implement 'cancelling the parent from a child'. Instead of passing in the cancel func from parent to child, the parent listens on a specific cancellation channel. The parent passes the channel to the child. Each time the child attempts to send an output to the output channel, it does so with a newly create time-out context. If that time-out occurs, then the child sends a cancellation notification on the cancel channel. The parent on seeing this cancelation request will invoke cancel on the context, resulting in the entire worker-pool shutting down.

See: