refactor(historian): gate before translate (no discarded alloc on secondary) + strengthen double-write warning (review)

This commit is contained in:
Joseph Doherty
2026-06-11 11:24:48 -04:00
parent bb42e5834a
commit e9355e9514
2 changed files with 14 additions and 24 deletions
@@ -29,12 +29,11 @@ public sealed class HistorianAdapterActorTests : RuntimeActorTestBase
/// <summary>Thread-safe fake sink that records every <see cref="EnqueueAsync"/> call.</summary>
private sealed class RecordingSink : IAlarmHistorianSink
{
private int _count;
private readonly object _lock = new();
private readonly List<AlarmHistorianEvent> _events = new();
/// <summary>The number of <see cref="EnqueueAsync"/> calls observed so far.</summary>
public int EnqueueCount => Volatile.Read(ref _count);
public int EnqueueCount { get { lock (_lock) { return _events.Count; } } }
/// <summary>A snapshot of every event enqueued so far (in arrival order).</summary>
public IReadOnlyList<AlarmHistorianEvent> Events
@@ -50,7 +49,6 @@ public sealed class HistorianAdapterActorTests : RuntimeActorTestBase
_events.Add(evt);
}
Interlocked.Increment(ref _count);
return Task.CompletedTask;
}