Compare arrivals at a barrier against the expected parties and turn the pending count into a release, wait, or escalate remediation action.

barrier pending The expected parties and arrivals are scalars, so the pending work that drives the remediation action stays deterministic without waiting on a live barrier.

Countdown Barrier Remediation Report

arrivals
CountdownBarrierRemediationReport.cs
Replay: real traced execution (multi-file project)
using System;

class Program
{
    static void Main()
    {
        int arrivals = 3;
        int parties = 3;
        int done = arrivals;
        if (done > parties)
        {
            done = parties;
        }
        int pending = parties - done;

        string action;
        if (pending == 0)
        {
            action = "release";
        }
        else if (pending <= 1)
        {
            action = "wait";
        }
        else
        {
            action = "escalate";
        }

        Console.WriteLine("parties=" + parties + " done=" + done + " pending=" + pending + " " + action);
    }
}
using System;

class Program
{
    static void Main()
    {
        int arrivals = 0;
        int parties = 3;
        int done = arrivals;
        if (done > parties)
        {
            done = parties;
        }
        int pending = parties - done;

        string action;
        if (pending == 0)
        {
            action = "release";
        }
        else if (pending <= 1)
        {
            action = "wait";
        }
        else
        {
            action = "escalate";
        }

        Console.WriteLine("parties=" + parties + " done=" + done + " pending=" + pending + " " + action);
    }
}
using System;

class Program
{
    static void Main()
    {
        int arrivals = 2;
        int parties = 3;
        int done = arrivals;
        if (done > parties)
        {
            done = parties;
        }
        int pending = parties - done;

        string action;
        if (pending == 0)
        {
            action = "release";
        }
        else if (pending <= 1)
        {
            action = "wait";
        }
        else
        {
            action = "escalate";
        }

        Console.WriteLine("parties=" + parties + " done=" + done + " pending=" + pending + " " + action);
    }
}
  1. arrivals ← 3, parties ← 3, done ← 3, pending ← 0

    4{5    static void Main()6    {7        int arrivals→ 3 = 3; //@arrivals=2, 08        int parties→ 3 = 3;9        int done→ 3 = arrivals3;10        if (done > parties)11        {12            done = parties;13        }14        int pending→ 0 = parties3 - done3;1516        string action;17        if (pending == 0)
  2. action ← release

    16string action;17if (pending0 == 0)18{19    action→ release = "release";20}
  3. Console.WriteLine("parties=" + parties + " done=" + done + " pending="…

    30    Console.WriteLine("parties=" + parties3 + " done=" + done3 + " pending=" + pending0 + " " + actionrelease);31}
    outputparties=3 done=3 pending=0 release
  1. arrivals ← 0, parties ← 3, done ← 0, pending ← 3

    4{5    static void Main()6    {7        int arrivals→ 0 = 0;8        int parties→ 3 = 3;9        int done→ 0 = arrivals0;10        if (done > parties)11        {12            done = parties;13        }14        int pending→ 3 = parties3 - done0;1516        string action;17        if (pending == 0)
  2. action ← escalate

    24}25else26{27    action→ escalate = "escalate";28}
  3. Console.WriteLine("parties=" + parties + " done=" + done + " pending="…

    30    Console.WriteLine("parties=" + parties3 + " done=" + done0 + " pending=" + pending3 + " " + actionescalate);31}
    outputparties=3 done=0 pending=3 escalate
  1. arrivals ← 2, parties ← 3, done ← 2, pending ← 1

    4{5    static void Main()6    {7        int arrivals→ 2 = 2;8        int parties→ 3 = 3;9        int done→ 2 = arrivals2;10        if (done > parties)11        {12            done = parties;13        }14        int pending→ 1 = parties3 - done2;1516        string action;17        if (pending == 0)
  2. action ← wait

    20}21else if (pending1 <= 1)22{23    action→ wait = "wait";24}
  3. Console.WriteLine("parties=" + parties + " done=" + done + " pending="…

    30    Console.WriteLine("parties=" + parties3 + " done=" + done2 + " pending=" + pending1 + " " + actionwait);31}
    outputparties=3 done=2 pending=1 wait