smol-rs / concurrent-queue

Concurrent multi-producer multi-consumer queue
Apache License 2.0
254 stars 21 forks source link

Add an overflow push method #58

Closed notgull closed 5 months ago

notgull commented 6 months ago

In some cases it is desired to have a "lossy" queue for data. Such as an event queue where more recent events should be prioritized over older ones, where infinite storage is impractical. This commit adds a method called "force_push" which enables this usage.

Bounded queue code is partially derived from the following commit: https://github.com/crossbeam-rs/crossbeam/commit/bd75c3c45edb78a731956c01458b75e5b69a8146

cc smol-rs/async-channel#44

fogti commented 4 months ago

Oh sorry, I'll keep that in mind to audit test suite updates more closely in the future for completeness and such.

notgull commented 4 months ago

More tests are added in https://github.com/smol-rs/concurrent-queue/pull/70