Concurrency Coordination Reports
Async Queue Coordination Report
Drain a cooperative work queue one item at a time and label the throughput from a deterministic count.
queue drain
A queue report removes each item in order and keeps the drained count scalar, so the drain order never varies.
Async Queue Coordination Report
async_queue.lua
Replay: real traced execution (multi-file project)
local pending = 4
local remaining = pending
local drained = 0
while remaining > 0 do
remaining = remaining - 1
drained = drained + 1
end
local report_status = "empty"
if drained >= 7 then
report_status = "backlog"
elseif drained > 0 then
report_status = "flowing"
end
print("pending=" .. pending .. " drained=" .. drained .. " status=" .. report_status)
local pending = 0
local remaining = pending
local drained = 0
while remaining > 0 do
remaining = remaining - 1
drained = drained + 1
end
local report_status = "empty"
if drained >= 7 then
report_status = "backlog"
elseif drained > 0 then
report_status = "flowing"
end
print("pending=" .. pending .. " drained=" .. drained .. " status=" .. report_status)
local pending = 7
local remaining = pending
local drained = 0
while remaining > 0 do
remaining = remaining - 1
drained = drained + 1
end
local report_status = "empty"
if drained >= 7 then
report_status = "backlog"
elseif drained > 0 then
report_status = "flowing"
end
print("pending=" .. pending .. " drained=" .. drained .. " status=" .. report_status)
pending ← 4, remaining ← 4, drained ← 0
1local pending→ 4 = 4 --@pending=0, 72local remaining→ 4 = pending43local drained→ 0 = 0remaining ← 3, drained ← 1
pass 1 of 45while remaining4 > 0 do6 remaining→ 3 = remaining - 17 drained→ 1 = drained + 18endAll 4 passes — pass 1 is the card above pass remainingdrained1 4 → 3 0 → 1 2 3 → 2 1 → 2 3 2 → 1 2 → 3 4 1 → 0 3 → 4 report_status ← empty
10local report_status→ empty = "empty"11if drained >= 7 thenreport_status ← flowing
12 report_status = "backlog"13elseif drained4 > 0 then14 report_status→ flowing = "flowing"15endprint("pending=" .. pending .. " drained=" .. drained .. " status=" ..…
17print("pending=" .. pending4 .. " drained=" .. drained4 .. " status=" .. report_statusflowing)outputpending=4 drained=4 status=flowing
pending ← 0, remaining ← 0, drained ← 0, report_status ← empty
1local pending→ 0 = 02local remaining→ 0 = pending03local drained→ 0 = 045while remaining > 0 do6 remaining = remaining - 17 drained = drained + 18end910local report_status→ empty = "empty"11if drained >= 7 then12 report_status = "backlog"13elseif drained > 0 then14 report_status = "flowing"15end1617print("pending=" .. pending0 .. " drained=" .. drained0 .. " status=" .. report_statusempty)outputpending=0 drained=0 status=empty
pending ← 7, remaining ← 7, drained ← 0
1local pending→ 7 = 72local remaining→ 7 = pending73local drained→ 0 = 0remaining ← 6, drained ← 1
pass 1 of 75while remaining7 > 0 do6 remaining→ 6 = remaining - 17 drained→ 1 = drained + 18endAll 7 passes — pass 1 is the card above pass remainingdrained1 7 → 6 0 → 1 2 6 → 5 1 → 2 3 5 → 4 2 → 3 4 4 → 3 3 → 4 5 3 → 2 4 → 5 6 2 → 1 5 → 6 7 1 → 0 6 → 7 report_status ← empty
10local report_status→ empty = "empty"11if drained >= 7 thenreport_status ← backlog
10local report_status = "empty"11if drained7 >= 7 then12 report_status→ backlog = "backlog"13elseif drained > 0 thenprint("pending=" .. pending .. " drained=" .. drained .. " status=" ..…
17print("pending=" .. pending7 .. " drained=" .. drained7 .. " status=" .. report_statusbacklog)outputpending=7 drained=7 status=backlog