Skip to content

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 ​

EntryDescription
deferSchedules routine to run after the current thread yields, passing any additional arguments to it. Returns the thread.
deferSelfYields the current thread and re-schedules it for the next resumption cycle.
delaySchedules routine to run after dur seconds, passing any additional arguments to it. Returns the thread.
resumeResumes thread, running it until it yields or completes. Returns the thread.
spawnSchedules routine to run immediately on the next resumption cycle, passing any additional arguments to it. Returns the thread.
waitYields 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...) -> thread

task.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...) -> thread

task.resume ​

Resumes thread, running it until it yields or completes. Returns the thread.

luau
(thread: thread) -> thread

task.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...) -> thread

task.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