SchedulerQueue<TAbsolute>
Efficient scheduler queue that maintains scheduled items sorted by absolute time.
            
                using System.Runtime.CompilerServices;
namespace System.Reactive.Concurrency
{
    [System.Runtime.CompilerServices.NullableContext(1)]
    [System.Runtime.CompilerServices.Nullable(0)]
    public class SchedulerQueue<[System.Runtime.CompilerServices.Nullable(0)] TAbsolute> where TAbsolute : IComparable<TAbsolute>
    {
        private readonly PriorityQueue<ScheduledItem<TAbsolute>> _queue;
        public int Count => _queue.Count;
        public SchedulerQueue()
            : this(1024)
        {
        }
        public SchedulerQueue(int capacity)
        {
            if (capacity < 0)
                throw new ArgumentOutOfRangeException("capacity");
            _queue = new PriorityQueue<ScheduledItem<TAbsolute>>(capacity);
        }
        public void Enqueue(ScheduledItem<TAbsolute> scheduledItem)
        {
            _queue.Enqueue(scheduledItem);
        }
        public bool Remove(ScheduledItem<TAbsolute> scheduledItem)
        {
            return _queue.Remove(scheduledItem);
        }
        public ScheduledItem<TAbsolute> Dequeue()
        {
            return _queue.Dequeue();
        }
        public ScheduledItem<TAbsolute> Peek()
        {
            return _queue.Peek();
        }
    }
}