docs(worker): record the SemaphoreSlim/STA dispatch invariant + single-waiter contract; harden fake

This commit is contained in:
Joseph Doherty
2026-08-15 17:13:17 -04:00
parent 25cbe5cd3e
commit 896d81e286
4 changed files with 47 additions and 4 deletions
@@ -303,6 +303,17 @@ internal sealed class FakeRuntimeSession : IWorkerRuntimeSession
if (BackingQueue is not null)
{
if (WaitForEventsOnSignalOnly)
{
// The two are mutually exclusive: a real backing queue owns its own signal and
// always honours the timeout, so silently letting it win would leave a
// signal-only test passing on a fallback tick — exactly the false green the
// option exists to rule out.
throw new InvalidOperationException(
"FakeRuntimeSession cannot combine BackingQueue with WaitForEventsOnSignalOnly: "
+ "the backing queue honours the fallback timeout, which defeats the signal-only wait.");
}
// Tests that drive a real queue enqueue into it directly, so the real queue owns the
// wake signal too.
return BackingQueue.WaitForEventsAsync(timeout, cancellationToken);