Thread
thread:create_heartbeat
Shared
Creates a new heartbeat context
Syntax
local ctx = thread:create_heartbeat(condition, exec, interval)Parameters
| Type | Name | Description |
|---|---|---|
function | condition | Conditional function - heartbeat continues while true, terminates when false |
function | exec | Callback function - executed upon heartbeat termination |
int | interval | Execution interval in milliseconds |
Returns
| Type | Name | Description |
|---|---|---|
thread / bool | ctx | thread instance on successful execution, or false on failure |
Examples
local counter = 0
local self = thread:create_heartbeat(
function()
return counter < 5
end,
function()
counter = counter + 1
engine.print("info", "Heartbeat terminated:", counter)
end, 1000
)