blob: fec32f38204dffaa2e9e4011c492c632a2ebf17b [file] [log] [blame]
using System.Threading;
using System.Threading.Tasks;
namespace DotPulsar.Abstractions
{
/// <summary>
/// A state change monitoring abstraction
/// </summary>
public interface IStateChanged<TState>
{
/// <summary>
/// Wait for the state to change to a specific state
/// </summary>
/// <returns>
/// The current state
/// </returns>
/// <remarks>
/// If the state change to a final state, then all awaiting tasks will complete
/// </remarks>
Task<TState> StateChangedTo(TState state, CancellationToken cancellationToken = default);
/// <summary>
/// Wait for the state to change from a specific state
/// </summary>
/// <returns>
/// The current state
/// </returns>
/// <remarks>
/// If the state change to a final state, then all awaiting tasks will complete
/// </remarks>
Task<TState> StateChangedFrom(TState state, CancellationToken cancellationToken = default);
/// <summary>
/// Ask whether the current state is final, meaning that it will never change
/// </summary>
/// <returns>
/// True if it's final and False if it's not
/// </returns>
bool IsFinalState();
/// <summary>
/// Ask whether the provided state is final, meaning that it will never change
/// </summary>
/// <returns>
/// True if it's final and False if it's not
/// </returns>
bool IsFinalState(TState state);
}
}