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 or blocked.
Guard Flag Coordination Report
guard_flag.lua
local claims =
local owner = "none"
local granted = 0
local blocked = 0
local claimed = false
for i = 1, claims do
if not claimed then
claimed = true
owner = "task" .. i
granted = granted + 1
else
blocked = blocked + 1
end
end
local report_status = "open"
if granted >= 1 and blocked >= 1 then
report_status = "contended"
elseif granted >= 1 then
report_status = "held"
end
print("claims=" .. claims .. " granted=" .. granted .. " blocked=" .. blocked .. " owner=" .. owner .. " status=" .. report_status)
local claims =
local owner = "none"
local granted = 0
local blocked = 0
local claimed = false
for i = 1, claims do
if not claimed then
claimed = true
owner = "task" .. i
granted = granted + 1
else
blocked = blocked + 1
end
end
local report_status = "open"
if granted >= 1 and blocked >= 1 then
report_status = "contended"
elseif granted >= 1 then
report_status = "held"
end
print("claims=" .. claims .. " granted=" .. granted .. " blocked=" .. blocked .. " owner=" .. owner .. " status=" .. report_status)
local claims =
local owner = "none"
local granted = 0
local blocked = 0
local claimed = false
for i = 1, claims do
if not claimed then
claimed = true
owner = "task" .. i
granted = granted + 1
else
blocked = blocked + 1
end
end
local report_status = "open"
if granted >= 1 and blocked >= 1 then
report_status = "contended"
elseif granted >= 1 then
report_status = "held"
end
print("claims=" .. claims .. " granted=" .. granted .. " blocked=" .. blocked .. " owner=" .. owner .. " status=" .. report_status)
guard flag
A guard flag grants the first claim and blocks the rest, so the granted count and owner stay deterministic scalars.