diff options
Diffstat (limited to 'subagents/jobs.lua')
| -rw-r--r-- | subagents/jobs.lua | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/subagents/jobs.lua b/subagents/jobs.lua index 9fe5c93..dc166a7 100644 --- a/subagents/jobs.lua +++ b/subagents/jobs.lua @@ -280,6 +280,21 @@ function handle_mt:cancel() end end +-- Cancel one known handle and wake parked awaiters. `handle:cancel()` remains +-- the narrow primitive; workflow records use this helper because cancelling a +-- queued child settles it synchronously. +function M.cancel(handle) + if getmetatable(handle) ~= handle_mt then + error("jobs.cancel expects a job handle", 2) + end + if handle.settled ~= nil then + return false + end + handle:cancel() + wake() + return true +end + -- start(startspec) -> handle | nil, err -- -- startspec = { |
