Ejemplo n.º 1
0
        /// <inheritdoc />
        public void DispatchNext()
        {
            IBeatEvent beatEvent = null;

            //Must lock around the isReady check to prevent potential dequeue races.
            lock (syncObj)
            {
                //Check if we're ready
                if (!isBeatEventReady)
                {
                    throw new InvalidOperationException($"Requested a beat event dispatch but {nameof(isBeatEventReady)} was false. Must check first.");
                }

                //Remove and delete
                beatEvent = EventQueue.FindMin();
                EventQueue.DeleteMin();
            }

            if (beatEvent == null)
            {
                throw new InvalidOperationException($"Failed to read beat event from the Beat {nameof(EventQueue)}.");
            }

            //Just dispatch the beat event
            beatEvent.Dispatch();
        }