Warning
- This function sets a debug hook function for all new Tasks, and may slow down program execution.
- Use it wisely and only for debugging purpose.
debug.settaskhook(func, mask, [count])
Sets/unsets the given function as the debug hook for all new Task instances.
When called without arguments, debug.settaskhook()
turns off the hook.
Parameters
func
A function
that represents the hook function.
mask
A string
describing in which conditions the hook will be called :
'c'
: the hook function is called every time the Task calls a function.'r'
: the hook function is called every time the Task returns from a function.'l'
: the hook function is called every time the Task enters a new line of code.[count]
An optional number
meaning that if non-zero, the hook function will also be called after each count instructions.
Return value
This function returns no value.Example
-- The hook function called for all Tasks after debug.settaskhook() call
local function hook(kind, line)
print("hook : "..kind, line or "")
end
-- Sets the debug hook function for all new Tasks (not those created before)
debug.settaskhook(hook, "clr")
-- Launch a new Task that prints "Hello LuaRT"
async(function()
local count = 4
while count > 0 do
print("Hello LuaRT !")
sleep(2000)
count = count-1
if count == 3 then
debug.settaskhook()
print("Task debug hook disabled !")
end
end
end)
waitall()