Concurrency Coordination Reports
Guard Flag Coordination Report
Let a boolean guard claim a single owner and report how many of the contending claims were granted.
Guard Flag Coordination Report
guard_flag_coordination.js
const claims = 2;
let owner = "none";
let granted = 0;
let blocked = 0;
function coordinate(count) {
let claimed = false;
for (let i = 1; i <= count; i++) {
if (!claimed) {
claimed = true;
owner = "task" + i;
granted += 1;
} else {
blocked += 1;
}
}
let outcome = "open";
if (granted >= 1 && blocked >= 1) {
outcome = "contended";
} else if (granted >= 1) {
outcome = "held";
}
console.log(`claims=${count} granted=${granted} blocked=${blocked} owner=${owner} status=${outcome}`);
}
coordinate(claims);
guard flag
A guard flag grants the first claim and blocks the rest, so the granted count and owner stay deterministic scalars.