coroutine
*このコンテンツは、ベータ版のAI(人工知能)を使用して翻訳されており、エラーが含まれている可能性があります。このページを英語で表示するには、 こちら をクリックしてください。
概要
関数
APIリファレンス
関数
close
finally
coroutine. finally(
パラメータ
callback:Variant |
コードサンプル
コルーチンの最終処理
local function observe(co, label)
coroutine.finally(co, function(status, ...)
print(label, status, ...)
end)
end
local finishing = coroutine.create(function()
return "結果"
end)
observe(finishing, "finishing") --> finishing finished result
coroutine.resume(finishing)
local failing = coroutine.create(function()
error("バン", 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