21 lines
678 B
Lua
21 lines
678 B
Lua
-- Showcase the calog task library: taskSelf reports this context's id,
|
|
-- taskSpawn launches a sibling "lua" child that runs its own code string and
|
|
-- calogPrints a message, taskCount reports how many contexts are now alive.
|
|
-- A short timer gives the child time to run before we exit, so its output lands.
|
|
-- Run: bin/calog examples/scripts/libraries/task.lua
|
|
|
|
calogPrint("self id:", taskSelf())
|
|
|
|
local childCode = [[
|
|
calogPrint("child says hello from task", taskSelf())
|
|
]]
|
|
|
|
local child = taskSpawn("lua", childCode)
|
|
calogPrint("spawned child handle:", child)
|
|
|
|
calogPrint("task count:", taskCount())
|
|
|
|
timerAfter(200, function()
|
|
taskClose(child)
|
|
calogExit(0)
|
|
end)
|