task
luau
local task = require("@lute/task")WARNING
These APIs are still open to future evolution. In new major versions, they may change in backwards incompatible ways.
Summary
| Entry | Description |
|---|---|
| defer | Schedules routine to run after the current thread yields, passing any additional arguments to it. Returns the thread. |
| deferSelf | Yields the current thread and re-schedules it for the next resumption cycle. |
| delay | Schedules routine to run after dur seconds, passing any additional arguments to it. Returns the thread. |
| resume | Resumes thread, running it until it yields or completes. 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.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.deferSelf
Yields the current thread and re-schedules it for the next resumption cycle.
luau
() -> ()task.delay
Schedules routine to run after dur seconds, passing any additional arguments to it. Returns the thread.
luau
(dur: number | time.Duration, routine: thread | ((T...) -> U...), ...: T...) -> threadtask.resume
Resumes thread, running it until it yields or completes. Returns the thread.
luau
(thread: thread) -> 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 | time.Duration)?) -> number