task
luau
local task = require("@std/task")WARNING
These APIs are still open to future evolution. In new major versions, they may change in backwards incompatible ways.
Summary
| Entry | Description |
|---|---|
| cancel | Cancels thread, preventing it from being resumed again. |
| defer | Schedules routine to run after the current thread yields, passing any additional arguments to it. Returns the thread. |
| delay | Schedules routine to run after dur seconds, passing any additional arguments to it. Returns the thread. |
| spawn | Schedules routine to run immediately on the next resumption cycle, passing any additional arguments to it. Returns the thread. |
| wait | Yields the current thread for dur seconds (or until the next cycle if dur is omitted). Returns the actual time waited. |
Functions and Properties
task.cancel
Cancels thread, preventing it from being resumed again.
luau
(thread: thread) -> ()task.defer
Schedules routine to run after the current thread yields, passing any additional arguments to it. Returns the thread.
luau
(routine: ((T...) -> U...) | thread, ...: T...) -> threadtask.delay
Schedules routine to run after dur seconds, passing any additional arguments to it. Returns the thread.
luau
(dur: number, routine: ((T...) -> U...) | thread, ...: T...) -> threadtask.spawn
Schedules routine to run immediately on the next resumption cycle, passing any additional arguments to it. Returns the thread.
luau
(routine: ((T...) -> U...) | thread, ...: T...) -> threadtask.wait
Yields the current thread for dur seconds (or until the next cycle if dur is omitted). Returns the actual time waited.
luau
(dur: number?) -> number