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
countdown_barrier_remediation_report.cpp
Replay: real traced execution (multi-file project)
#include <iostream>
#include <string>

int main() {
    int arrivals = 3;
    const int parties = 3;
    int done = arrivals;
    if (done > parties) {
        done = parties;
    }
    int pending = parties - done;

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

    std::cout << "parties=" << parties
              << " done=" << done
              << " pending=" << pending
              << " " << action << std::endl;
    return 0;
}
#include <iostream>
#include <string>

int main() {
    int arrivals = 0;
    const int parties = 3;
    int done = arrivals;
    if (done > parties) {
        done = parties;
    }
    int pending = parties - done;

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

    std::cout << "parties=" << parties
              << " done=" << done
              << " pending=" << pending
              << " " << action << std::endl;
    return 0;
}
#include <iostream>
#include <string>

int main() {
    int arrivals = 2;
    const int parties = 3;
    int done = arrivals;
    if (done > parties) {
        done = parties;
    }
    int pending = parties - done;

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

    std::cout << "parties=" << parties
              << " done=" << done
              << " pending=" << pending
              << " " << action << std::endl;
    return 0;
}
  1. arrivals ← 3, parties ← 3, done ← 3, pending ← 0, action ← (empty)

    4int main() {5    int arrivals→ 3 = 3; //@arrivals=2, 06    const int parties→ 3 = 3;7    int done→ 3 = arrivals3;8    if (done > parties) {9        done = parties;10    }11    int pending→ 0 = parties3 - done3;1213    std::string action→ (empty);14    if (pending == 0) {
  2. action ← release

    13std::string action;14if (pending0 == 0) {15    action→ release = "release";16} else if (pending <= 1) {
  3. std::cout << "parties=" << parties

    22    std::cout << "parties=" << parties323              << " done=" << done324              << " pending=" << pending025              << " " << actionrelease << std::endl;26    return 0;27}
    outputparties=3 done=3 pending=0 release
  1. arrivals ← 0, parties ← 3, done ← 0, pending ← 3, action ← (empty)

    4int main() {5    int arrivals→ 0 = 0;6    const int parties→ 3 = 3;7    int done→ 0 = arrivals0;8    if (done > parties) {9        done = parties;10    }11    int pending→ 3 = parties3 - done0;1213    std::string action→ (empty);14    if (pending == 0) {
  2. action ← escalate

    17    action = "wait";18} else {19    action→ escalate = "escalate";20}
  3. std::cout << "parties=" << parties

    22    std::cout << "parties=" << parties323              << " done=" << done024              << " pending=" << pending325              << " " << actionescalate << std::endl;26    return 0;27}
    outputparties=3 done=0 pending=3 escalate
  1. arrivals ← 2, parties ← 3, done ← 2, pending ← 1, action ← (empty)

    4int main() {5    int arrivals→ 2 = 2;6    const int parties→ 3 = 3;7    int done→ 2 = arrivals2;8    if (done > parties) {9        done = parties;10    }11    int pending→ 1 = parties3 - done2;1213    std::string action→ (empty);14    if (pending == 0) {
  2. action ← wait

    15    action = "release";16} else if (pending1 <= 1) {17    action→ wait = "wait";18} else {
  3. std::cout << "parties=" << parties

    22    std::cout << "parties=" << parties323              << " done=" << done224              << " pending=" << pending125              << " " << actionwait << std::endl;26    return 0;27}
    outputparties=3 done=2 pending=1 wait