コード例 #1
0
            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);
            }
コード例 #2
0
 public bool Equals(PrioritizedItem <T> other) => EqualityComparer <T> .Default.Equals(Item, other.Item) && EqualityComparer <int> .Default.Equals(Priority, other.Priority);
コード例 #3
0
        private async Task <T> UnwrapAsync(ValueTask <PrioritizedItem <T> > prioritizedItemTask)
        {
            PrioritizedItem <T> result = await prioritizedItemTask.ConfigureAwait(false);

            return(result.Item);
        }
コード例 #4
0
 public bool TryAdd(PrioritizedItem <T> item)
 {
     _itemQueues[item.Priority].Enqueue(item.Item);
     return(true);
 }