Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@rbxts/luau-thread

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rbxts/luau-thread

Parallel Luau library designed for simplicity and ease of use.

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

Thread

Fork of luau-thread for Roblox-ts

The module must first export a function:

// src/shared/module
export = function(timeToWait: number) {
	task.wait(timeToWait);
	print("waited", timeToWait, "second(s)");
}

Then, to get our module, we can use the new $getModuleTree macro, and the function provided in this library

import Thread from "@rbxts/luau-thread";

const [root, parts] = $getModuleTree("shared/module");
const module = Thread.getModuleByTree(root, parts);

Afterwards, we can spawn the module and wait for it to finish:

const identifier = Thread.spawn(module, 1);
Thread.join(identifier);

// prints: waited 1 second(s)

We can also spawn it multiple times, and wait for all threads to finish:

const identifiers = [];

for (const i of $range(1, 10)) {
	identifiers.push(Thread.spawn(module, i));
}

Thread.join(identifiers);

// prints: waited 1 second(s)
// ...
// prints: waited 10 seconds(s)

FAQs

Package last updated on 12 Jul 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts