Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overflow mode #44

Closed
alandiwix opened this issue Jan 20, 2022 · 3 comments · Fixed by #89
Closed

Overflow mode #44

alandiwix opened this issue Jan 20, 2022 · 3 comments · Fixed by #89

Comments

@alandiwix
Copy link

Would it be possible to have overflow mode (similar to one in async_broadcast) in this implementation? Would be nice to have this mode for a channel that doesn't require Clone for messages.

@zjijz
Copy link

zjijz commented Apr 20, 2022

I also have a use case where I want an async SPSC bounded channel that follows the overflow method of async-broadcast when the channel is filled instead of blocking new sends. I was thinking something that would be inherent to the channel itself, so adding a creation function like async_channel::bounded_circular instead of a mutable overflow mode set.

I can use async-broadcast for my case as well so I'm not blocked.

@taiki-e
Copy link
Collaborator

taiki-e commented Jun 7, 2022

This should be possible to do after adding a function similar to crossbeam-rs/crossbeam@bd75c3c to concurrent-queue.

notgull added a commit to smol-rs/concurrent-queue that referenced this issue Feb 11, 2024
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:
crossbeam-rs/crossbeam@bd75c3c

cc smol-rs/async-channel#44

Signed-off-by: John Nunley <[email protected]>
notgull added a commit to smol-rs/concurrent-queue that referenced this issue Mar 30, 2024
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:
crossbeam-rs/crossbeam@bd75c3c

cc smol-rs/async-channel#44
@notgull
Copy link
Member

notgull commented Apr 7, 2024

This function has been added to concurrent-queue. Once it's released we can implement this functionality.

notgull added a commit that referenced this issue May 5, 2024
Closes #44 by adding a "force_send" method. This method can replace an
existing element in the list, in which case that element is returned.
This can be used to make "limited capacity" channels.

Signed-off-by: John Nunley <[email protected]>
notgull added a commit that referenced this issue May 6, 2024
Closes #44 by adding a "force_send" method. This method can replace an
existing element in the list, in which case that element is returned.
This can be used to make "limited capacity" channels.

Signed-off-by: John Nunley <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

4 participants