bounded-spsc-queue icon indicating copy to clipboard operation
bounded-spsc-queue copied to clipboard

Feature request: force-push

Open jakalope opened this issue 7 years ago • 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.

jakalope avatar Apr 29 '18 18:04 jakalope

++ 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.

polyfractal avatar May 15 '18 01:05 polyfractal