Skip to main content

Tasks

A utility for managing concurrent tasks and awaiting their completion.

Functions

new

Tasks.new() → Tasks

Creates a new Tasks instance.

add

Tasks.add(
selfTasks,
callback(...any) → ...any,
...any
) → ()

Adds a new task to be executed concurrently.

wait

Tasks.wait(selfTasks) → {{any}}?

Waits for all tasks to complete, returning the results in a list.

waitForFirst

Tasks.waitForFirst(selfTasks) → (
boolean,
...any
)

Waits for the first task to complete, returning the function's success and its results.

Show raw api
{
    "functions": [
        {
            "name": "new",
            "desc": "Creates a new Tasks instance.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Tasks\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 17,
                "path": "src/Util/Tasks.luau"
            }
        },
        {
            "name": "add",
            "desc": "Adds a new task to be executed concurrently.",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "Tasks"
                },
                {
                    "name": "callback",
                    "desc": "",
                    "lua_type": "(...any) -> ...any"
                },
                {
                    "name": "...",
                    "desc": "",
                    "lua_type": "any"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 45,
                "path": "src/Util/Tasks.luau"
            }
        },
        {
            "name": "wait",
            "desc": "Waits for all tasks to complete, returning the results in a list.",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "Tasks"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{ { any } }?\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 52,
                "path": "src/Util/Tasks.luau"
            }
        },
        {
            "name": "waitForFirst",
            "desc": "Waits for the first task to complete, returning the function's success and its results.",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "Tasks"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean"
                },
                {
                    "desc": "",
                    "lua_type": "...any"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 61,
                "path": "src/Util/Tasks.luau"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "Tasks",
    "desc": "A utility for managing concurrent tasks and awaiting their completion.",
    "source": {
        "line": 3,
        "path": "src/Util/Tasks.luau"
    }
}