Concurrency Coordination Reports
Microtask Checkpoint Coordination Report
Await a fixed number of microtask checkpoints in order and report the resume sequence and drain state.
Microtask Checkpoint Coordination Report
microtask_checkpoint_coordination.js
const seedTasks = 2;
let checkpoints = 0;
let order = "";
async function coordinate(count) {
for (let i = 1; i <= count; i++) {
await Promise.resolve(i);
checkpoints += 1;
order += i;
}
let outcome = "idle";
if (checkpoints >= 3) {
outcome = "drained";
} else if (checkpoints === 2) {
outcome = "checked";
} else if (checkpoints === 1) {
outcome = "primed";
}
console.log(`tasks=${count} checkpoints=${checkpoints} order=${order} status=${outcome}`);
}
coordinate(seedTasks);
microtask checkpoint
Each await yields to the microtask queue and resumes in order, so the checkpoint count and resume sequence stay deterministic.