polyfractal/bounded-spsc-queue

Feature request: force-push

jakalope opened this issue · 1 comments

In low-latency applications, it's often desirable to drop old items from the queue in favor of newer items. A suitable interface might be something like:

fn force_push(&self, v: T) -> option<T>

where the return value is None or, if the oldest element was dropped, Some(old_value).

Such a function would be non-blocking, of course.

++ I agree, this would be useful. I won't be able to work on this any time soon, but would happily accept a PR to add it (from you or anyone else).

The concurrency semantics will be a bit trickier. It'll have to be more careful about not stomping on the consumer if they're trying to process the same slot, whereas right now the semantics are easy as they can never pass each other. But it should be doable I think.