-
-
Notifications
You must be signed in to change notification settings - Fork 28
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Wonder if allowing to cancel existing SendRef would be possible? E.g. something along the lines of
impl<'a, ...> SendRef<'a, ...> {
/// Drops this send ref *without* sending the data. The slot is returned to the pool.
pub fn cancel(self) {
...
}
}Here's a particular sample use case:
- We're reading network messages from multiple threads into a single thingbuf, trying to avoid all allocations and copying if possible (and recycling really helps with that).
- Reading those messages is a complicated process - they don't arrive as
&[u8]but have to be combined and processed in a streaming fashion, so each message is aBufReadreader. - In order to avoid copying, we reserve a
SendRefslot and.read_to_end()directly into it. - However, sometimes it turns out that those messages have to be filtered out and should never reach the thingbuf receiver...
- ... but alas, it's too late. As soon as
SendRefis dropped, it will be sent away. - We can either use some hacky convention like sending empty messages, or some enums, or maybe do reading into a separate buffer first - all of these will work as workarounds, but the cleanest way would be to able to
send_ref.cancel()which would cancel the reservation and return the slot to the pool - hence this question.
Thanks!
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request