rustchannelreceiversender

Sender-side deleting pending messages in mpsc channel


Please is there a way for sender to delete pending messages sent to mpsc channel (or crossbeam-channel or equivalent) which have not been consumed by the receiver yet? Something like sender.deleteAllPending().


Solution

  • You can't do that with mspc which is "single consumer".

    With crossbeam, you can have multiple receivers. So you can clone and keep a receiver "sender side", so you can drain it.