feat(galaxy): writer borrows live subscription item handles (skip redundant AddItem)
GatewayGalaxyDataWriter now accepts an optional subscribedHandleSource delegate; TryResolveCachedOrBorrowed checks _itemHandles first then the source, so the first write to an already-subscribed tag skips the AddItem round-trip. Borrowed handles are not cached (subscription registry owns lifecycle). AddItemCallCount seam confirms gateway calls.
This commit is contained in:
@@ -195,10 +195,10 @@ public sealed class GatewayGalaxyDataWriter : IGalaxyDataWriter
|
||||
private async Task<int> EnsureItemHandleAsync(
|
||||
MxGatewaySession session, int serverHandle, string fullRef, CancellationToken ct)
|
||||
{
|
||||
if (_itemHandles.TryGetValue(fullRef, out var existing)) return existing;
|
||||
if (TryResolveCachedOrBorrowed(fullRef) is int resolved) return resolved;
|
||||
var handle = await session.AddItemAsync(serverHandle, fullRef, ct).ConfigureAwait(false);
|
||||
_itemHandles[fullRef] = handle;
|
||||
Interlocked.Increment(ref _addItemCallCount);
|
||||
_itemHandles[fullRef] = handle;
|
||||
return handle;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user