-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
[API Proposal] Channel.CreateBoundedPrioritized #101292
Comments
What behavior are you proposing, and why aren't there any other valid behaviors? |
On second thought I think it should be possible to implement all FullMode options. The DropNewest could probably drop the least prioritized and the DropOldest could drop the item next in turn. It might however be worth implementing new options as it is not crystal clear what item to drop otherwise. public enum BoundedPrioritizedChannelFullMode
{
/// <summary>Wait for space to be available in order to complete the write operation.</summary>
Wait,
/// <summary>Remove and ignore the least prioritized item in the channel in order to make room for the item being written.</summary>
DropLeastPrioritized,
/// <summary>Remove and ignore the most prioritized item in the channel in order to make room for the item being written.</summary>
DropMostPrioritized,
/// <summary>Drop the item being written.</summary>
DropWrite
} |
I wrote a priority The assumption to get the highest priority item by using a simple There should be a counter for each item that should be passed to the Example:
The |
What would a valid workaround to this be today? I assume one would need 2 channels: one for "normal" priority items, and another for "high priority" ones, and then have the consumer check the high priority channel first? |
Don't really know what's the best/performant solution is, To use multiple channels for this feature is only a workaround. I would have two ideas, they could be used both together:
|
By the way the ordering need to be declared or optional possible to set. |
I had one more idea what could be simple to implement. Beside to taking an instance of a comparer, the Channel could take a With the combination of the item-position the user could implement a proper priority algorithms |
Background and motivation
This is a follow up to the UnboundedPrioritizedChannel #62761
It would be nice to have a prioritized bounded channel so that consumers could work on the highest priority item in a channel while still being able to limit the number of items held in the channel.
cc: @stephentoub
API Proposal
API Usage
Alternative Designs
No response
Risks
I may be hard to understand what happens when items with higher priority are written to the channel when the channel has reached capacity, but I don't think there is ant other option that is valid.
The text was updated successfully, but these errors were encountered: