namespace ZB.MOM.WW.ScadaBridge.CentralUI.Services; /// Reentrancy guard for poll timers: a fixed-period Timer whose refresh outlives /// the period stacks overlapping fan-outs against an already-degraded site (arch-review S3). /// Callers TryEnter at tick start and skip the tick when the previous refresh is in flight. public sealed class PollGate { private int _inFlight; /// Attempts to enter the gate for a new poll tick. /// if no refresh is currently in flight and the caller /// may proceed; if a previous refresh is still running. public bool TryEnter() => Interlocked.CompareExchange(ref _inFlight, 1, 0) == 0; /// Releases the gate after a poll tick's refresh has completed. public void Exit() => Volatile.Write(ref _inFlight, 0); }