Skip to main content

Thread

The Thread class is used to handle all forms of operation management. Additionally, it manages the thread being used to run all of the queued operations.

Functions

new

Thread.new(
optionsThreadOptions--

The initial configuration for the class.

) → Thread

Types

interface ThreadOptions {
Intervalnumber?--

The interval to run operations at (default 0.01).

OperationLimitnumber?--

The number of operations to run each step (default 5).

}

This function creates a new instance of the Thread class.

Spawn

Thread:Spawn() → Thread

This function spawns a thread to process operations. There can only be one thread running at once.

Stop

Thread:Stop() → Thread

This function stops the current thread.

ThreadActive

Thread:ThreadActive() → boolean

This function returns true if the Thread currently has a working thread.

GetCurrentId

Thread:GetCurrentId() → string?

This function returns the current thread id if there is a working thread.

QueueOperation

Thread:QueueOperation(operation(
number?,
) → nil) → Thread

This function queues a function to be executed by the Thread.

AdjustInterval

Thread:AdjustInterval(intervalnumber) → Thread

This function adjusts the interval at which the Thread executes operations at.

AdjustOperationLimit

Thread:AdjustOperationLimit(limitnumber) → Thread

This function adjusts the operation limit for each frame.

Destroy

Thread:Destroy() → ()

This function destroys the Thread instance.

Show raw api
{
    "functions": [
        {
            "name": "new",
            "desc": "This function creates a new instance of the Thread class.",
            "params": [
                {
                    "name": "options",
                    "desc": "The initial configuration for the class.",
                    "lua_type": "ThreadOptions"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Thread"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 54,
                "path": "src/Commons/Thread.luau"
            }
        },
        {
            "name": "Spawn",
            "desc": "This function spawns a thread to process operations.  There can only be one thread running at once.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Thread"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 70,
                "path": "src/Commons/Thread.luau"
            }
        },
        {
            "name": "Stop",
            "desc": "This function stops the current thread.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Thread"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 98,
                "path": "src/Commons/Thread.luau"
            }
        },
        {
            "name": "ThreadActive",
            "desc": "This function returns true if the Thread currently has a working thread.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 114,
                "path": "src/Commons/Thread.luau"
            }
        },
        {
            "name": "GetCurrentId",
            "desc": "This function returns the current thread id if there is a working thread.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "string?"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 128,
                "path": "src/Commons/Thread.luau"
            }
        },
        {
            "name": "QueueOperation",
            "desc": "This function queues a function to be executed by the Thread.",
            "params": [
                {
                    "name": "operation",
                    "desc": "",
                    "lua_type": "(number?, Thread?) -> nil"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Thread"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 143,
                "path": "src/Commons/Thread.luau"
            }
        },
        {
            "name": "AdjustInterval",
            "desc": "This function adjusts the interval at which the Thread executes operations at.",
            "params": [
                {
                    "name": "interval",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Thread"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 156,
                "path": "src/Commons/Thread.luau"
            }
        },
        {
            "name": "AdjustOperationLimit",
            "desc": "This function adjusts the operation limit for each frame.",
            "params": [
                {
                    "name": "limit",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Thread"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 169,
                "path": "src/Commons/Thread.luau"
            }
        },
        {
            "name": "Destroy",
            "desc": "This function destroys the Thread instance.\n\t",
            "params": [],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 180,
                "path": "src/Commons/Thread.luau"
            }
        }
    ],
    "properties": [],
    "types": [
        {
            "name": "ThreadOptions",
            "desc": "",
            "fields": [
                {
                    "name": "Interval",
                    "lua_type": "number?",
                    "desc": "The interval to run operations at (default 0.01)."
                },
                {
                    "name": "OperationLimit",
                    "lua_type": "number?",
                    "desc": "The number of operations to run each step (default 5)."
                }
            ],
            "source": {
                "line": 10,
                "path": "src/Commons/Thread.luau"
            }
        }
    ],
    "name": "Thread",
    "desc": "The Thread class is used to handle all forms of operation management.  Additionally, it manages the thread being used to run all of the queued operations.",
    "source": {
        "line": 42,
        "path": "src/Commons/Thread.luau"
    }
}