Tasks
Runs concurrent tasks and awaits their completion.
Constructors: Tasks.new
Types
self type
luau
type self = {
_numTasks: number,
_results: { any },
_returnFirstResult: boolean,
_running: thread,
_waiting: boolean,
}Tasks type
luau
type Tasks = typeof(setmetatable({} :: self, Tasks))Functions
new
luau
Tasks.new(): TasksCreates a new task group.
Methods
add
luau
Tasks:add(callback: (...any) -> ...any, ...: any)Schedules callback to run concurrently.
wait Yields
luau
Tasks:wait(): { { any } }?Yields until all running tasks finish and returns their { ok, ... } results.
waitForFirst Yields
luau
Tasks:waitForFirst(): (boolean, ...any)Yields until the first task finishes and returns its (ok, ...) result.