add coroutine

This commit is contained in:
2022-03-08 20:08:50 +08:00
parent db47163e39
commit 4df12ebbec
4 changed files with 30 additions and 0 deletions
+13
View File
@@ -0,0 +1,13 @@
local function sleep(n)
os.execute("sleep " .. tonumber(n))
end
local co = coroutine.create(function(x)
sleep(3)
print("co -> ", x)
end)
coroutine.resume(co, 42)
ngx.say("main")