public bool TryTake(out PrioritizedItem <T> item) { for (int priority = 0; priority < _itemQueues.Length; priority++) { T itemValue; if (_itemQueues[priority].TryDequeue(out itemValue)) { item = new PrioritizedItem <T>(itemValue, priority); return(true); } } item = default(PrioritizedItem <T>); return(false); }
public bool Equals(PrioritizedItem <T> other) => EqualityComparer <T> .Default.Equals(Item, other.Item) && EqualityComparer <int> .Default.Equals(Priority, other.Priority);
private async Task <T> UnwrapAsync(ValueTask <PrioritizedItem <T> > prioritizedItemTask) { PrioritizedItem <T> result = await prioritizedItemTask.ConfigureAwait(false); return(result.Item); }
public bool TryAdd(PrioritizedItem <T> item) { _itemQueues[item.Priority].Enqueue(item.Item); return(true); }