Open
Description
I believe Sender::send()
is not cancel safe in regard that it takes ownership of the value to be sent. If the future is cancelled, the value is gone with no way to recover it. This makes using it inconvenient within the select!
loop.
tokio's mpsc::Sender
suggests using reserve()
and Permit::send()
to resolve this problem. reserve()
returns a future, but it does not consume any value by itself. Permit::send()
then can be used to send the value without any blocking.
Can a similar API be implemented for async-channel? Is that feasible?
[1] https://docs.rs/tokio/latest/tokio/macro.select.html
[2] https://docs.rs/tokio/latest/tokio/sync/mpsc/struct.Sender.html#cancel-safety
Metadata
Metadata
Assignees
Labels
No labels