coroutine
Summary
Functions
API Reference
Functions
close
create
finally
coroutine. finally(
Parameters
callback:Variant |
Code Samples
Coroutine Finally
local function observe(co, label)
coroutine.finally(co, function(status, ...)
print(label, status, ...)
end)
end
local finishing = coroutine.create(function()
return "result"
end)
observe(finishing, "finishing") --> finishing finished result
coroutine.resume(finishing)
local failing = coroutine.create(function()
error("boom", 0)
end)
observe(failing, "failing") --> failing error boom
coroutine.resume(failing)
local cancelled = coroutine.create(function()
coroutine.yield()
end)
coroutine.resume(cancelled)
observe(cancelled, "cancelled") --> cancelled cancelled
coroutine.close(cancelled)resume
status
wrap