[API Proposal]: ChannelOptions.ProcessingOrder
- Dominant language
- C#
- Stars
- 18.3k
- Forks
- 5.6k
- PR merge metrics
- PR metrics pending
Description
### Background and motivation
Today's Channels are essentially Queue-based.
In our application, this causes us to process information breadth-first which, for us, is much more memory intensive.
A stack-based method would let us process things depth-first and would drastically reduce memory.
### API Proposal
```csharp
namespace System.Threading.Channels;
public enum ChannelProcessingOrder {
Queue,
Stack,
}
public class ChannelOptions
{
public ChannelProcessingOrder ProcessingOrder {get; set;} = ChannelProcessingOrder,Queue;
}
```
### API Usage
```csharp
var Options = new BoundedChannelOptions(){ //Inherits from ChannelOptions
ProcessingOrder = ChannelProcessingOrder.Stack,
};
```
### Alternative Designs
Channels could be adapted so that the backing collection type could be provided. This would allow priority-queue scenarios. However, this might be overkill and could likely create a surface area for bugs.
### Risks
Because of threading and concurrency, the order is not strictly guaranteed to be stack or queue. It is actually stack-ish or queue-ish. Someone might think the order is strictly guaranteed.
Contributor guide
Assessment
This issue has not been assessed yet.