perf(drivers): fixed-rate poll pacing with overrun counter; non-blocking unsubscribe

This commit is contained in:
Joseph Doherty
2026-08-16 04:26:20 -04:00
parent 684e59d871
commit 9cf400f1e8
9 changed files with 277 additions and 43 deletions
@@ -1341,13 +1341,14 @@ public sealed class ModbusDriver
Task.FromResult(_poll.Subscribe(fullReferences, publishingInterval));
/// <inheritdoc />
public Task UnsubscribeAsync(ISubscriptionHandle handle, CancellationToken cancellationToken)
public async Task UnsubscribeAsync(ISubscriptionHandle handle, CancellationToken cancellationToken)
{
_poll.Unsubscribe(handle);
// Async teardown: the engine drains the in-flight poll without blocking the caller's
// thread — this runs inside a DriverInstanceActor mailbox turn.
await _poll.UnsubscribeAsync(handle).ConfigureAwait(false);
// Drop any partially-collected cycle buffer so a torn-down subscription leaks nothing.
// Unsubscribe awaits the loop task, so no onChange can re-add after this point.
// The teardown above awaits the loop task, so no onChange can re-add after this point.
_cycleBatchItems.TryRemove(handle, out _);
return Task.CompletedTask;
}
// ---- IHostConnectivityProbe ----