docs(code): close-out comment fixes from the follow-ups review round

This commit is contained in:
Joseph Doherty
2026-08-17 04:32:53 -04:00
parent 57c66416d8
commit 7c5a843ace
5 changed files with 28 additions and 4 deletions
@@ -1036,6 +1036,9 @@ public sealed class ScriptedAlarmEngine : IDisposable
Task work;
try
{
// The null coalesce is defensive only: no current caller can return a null Task
// (every factory is an async lambda or returns a started Task). It costs nothing and
// keeps a future non-async factory from NREing the continuation wiring below.
work = factory() ?? Task.CompletedTask;
}
catch (Exception ex)
@@ -1057,6 +1060,9 @@ public sealed class ScriptedAlarmEngine : IDisposable
// so Dispose's WhenAll still observes (and logs) a background failure.
work.ContinueWith(t =>
{
// Removing BEFORE completing the placeholder is safe (not a window where Dispose could
// miss still-running work): this continuation only runs once the REAL task has already
// finished, so anything a concurrent Dispose could still be waiting for is done.
lock (_inFlightLock) { _inFlight.Remove(placeholder.Task); }
if (t.IsFaulted)
{