﻿namespace Disruptor
{
    public interface ISequenceBarrier
    {
        /// <summary>
        /// Wait for the given sequence to be available for consumption.
        /// </summary>
        /// <param name="sequence">The sequence to wait for.</param>
        /// <returns>The sequence up to which is available.</returns>
        long WaitFor(long sequence);

        /// <summary>
        /// Get the current cursor value that can be read.
        /// </summary>
        long Cursor { get; }

        /// <summary>
        /// The current alert status for the barrier.
        /// </summary>
        bool IsAlerted { get; }

        /**
     * Alert the {@link EventProcessor}s of a status change and stay in this status until cleared.
     */
        void Alert();

        /**
         * Clear the current alert status.
         */
        void ClearAlert();

        /**
         * Check if an alert has been raised and throw an {@link AlertException} if it has.
         *
         * @throws AlertException if alert has been raised.
         */
        void CheckAlert();
    }
}