perf(drivers): fixed-rate poll pacing with overrun counter; non-blocking unsubscribe
This commit is contained in:
@@ -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 ----
|
||||
|
||||
Reference in New Issue
Block a user