namespace MinicsConsole.Helper.RawDataFilter;

internal class Mini8DataQueue : IMini8DataFilter, IDisposable
{
    public Mini8DataQueue()
    {
        this._InputQueue = new(OutputQueueHandler);
    }

    public IDataSender? NextSender { get; set; }

    private readonly EventQueue<(Mini8Output mini8Output, ChannelData channelData)> _InputQueue;

    public bool Send(Mini8Output mini8Output, ChannelData channelData, object? state)
    {
        this._InputQueue.Enqueue((mini8Output, channelData));
        return true;
    }

    private void OutputQueueHandler((Mini8Output mini8Output, ChannelData channelData) item)
    {
        this.NextSender?.Send(item.mini8Output, item.channelData, null);
    }

    public void Dispose()
    {
        this._InputQueue?.Dispose();
    }
}