Home › Overview › MainModule › Util
Tasks
A utility for managing concurrent tasks and awaiting 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 Tasks instance.
Methods
add
luau
Tasks:add(callback: (...any) -> ...any, ...: any)Adds a new task to be executed concurrently.
wait Yields
luau
Tasks:wait(): { { any } }?Waits for all tasks to complete, returning the results in a list.
waitForFirst Yields
luau
Tasks:waitForFirst(): (boolean, ...any)Waits for the first task to complete, returning the function's success and its results.