using XFEWorkflow.Abstractions;
namespace XFEWorkflow.Infrastructure.Execution;
/// <summary>Retains only the latest selected workflow update, never a UI callback per event.</summary>
public sealed class RunUpdateBuffer
{
private readonly object gate = new();
private string? workflowId;
private RunRecord? pending;
public void Select(string? id)
{
lock (gate) { if (workflowId == id) return; workflowId = id; pending = null; }
}
public void Publish(RunRecord record)
{
lock (gate) if (record.WorkflowId == workflowId) pending = record;
}
public RunRecord? TakeLatest()
{
lock (gate) { var result = pending; pending = null; return result; }
}
}
using XFEWorkflow.Abstractions;
namespace XFEWorkflow.Infrastructure.Execution;
/// <summary>Retains only the latest selected workflow update, never a UI callback per event.</summary>
public sealed class RunUpdateBuffer
{
private readonly object gate = new();
private string? workflowId;
private RunRecord? pending;
public void Select(string? id)
{
lock (gate) { if (workflowId == id) return; workflowId = id; pending = null; }
}
public void Publish(RunRecord record)
{
lock (gate) if (record.WorkflowId == workflowId) pending = record;
}
public RunRecord? TakeLatest()
{
lock (gate) { var result = pending; pending = null; return result; }
}
}