test(grpc-data): A2 review N5 — the waiter test counts condition-queue waits only (red on revert: 19 vs ≤ 1)

This commit is contained in:
Joseph Doherty
2026-11-24 14:59:01 -05:00
parent 20bf937259
commit c709fbc1c4
2 changed files with 4 additions and 4 deletions
@@ -237,13 +237,13 @@ internal sealed partial class DataSubscriptionSession
private Task<bool> StartWait(ChannelReader<PendingDelivery> reader, CancellationToken token)
{
Interlocked.Increment(ref _conditionWaitsStarted);
if (!ReferenceEquals(reader, _outbound.Reader)) Interlocked.Increment(ref _conditionWaitsStarted);
return reader.WaitToReadAsync(token).AsTask();
}
private int _conditionWaitsStarted;
/// <summary>Test seam (N5): how many channel waits the delivery loop has registered.</summary>
/// <summary>Test seam (N5): how many waits on the CONDITION queue the delivery loop has registered.</summary>
internal int ConditionWaitsStartedForTests => Volatile.Read(ref _conditionWaitsStarted);
/// <summary>Test seam: the stream has processed its Open.</summary>
@@ -274,8 +274,8 @@ public sealed class GrpcDataConditionStreamTests
await stream.Session.EnqueueValueProbeForTests();
(await next).ShouldNotBeNull();
}
// Each value wakes the loop once; the idle condition wait must be reused, not re-registered every pass.
(stream.Session.ConditionWaitsStartedForTests - before).ShouldBeLessThan(50);
// Values wake the loop; the idle condition queue's wait must be reused, not re-registered on every pass.
(stream.Session.ConditionWaitsStartedForTests - before).ShouldBeLessThanOrEqualTo(1);
}
[Fact]