Biblioteca del motor
coroutine
*Este contenido se traduce usando la IA (Beta) y puede contener errores. Para ver esta página en inglés, haz clic en aquí.
Resumen
Funciones
Referencia API
Funciones
close
create
finally
coroutine.finally(
Parámetros
callback:Variant |
Muestras de código
Coroutine Finalmente
local function observe(co, label)
coroutine.finally(co, function(status, ...)
print(label, status, ...)
end)
end
local finishing = coroutine.create(function()
return "resultado"
end)
observe(finishing, "finishing") --> finishing finished resultado
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 cancelado
coroutine.close(cancelled)resume
status
wrap