Start typing to search packages!
threader
By @jammees
Roblox
MirroredPromise based Actor wrapper.
Version: 1.0.1
Threader is Easy to Use, Promise Based and uses Send Data Get Data structure. Threader was made to make working with Actors easier and overall tie everything together. Once Threader had dispatched the work and all the threads had finished, it will return all of the data that the threads had returned.
Showcase
Creating a Threader Class
Creating a Threader class is very simple. The first argument is always how many threads are there initially and the last one is the ThreadWorker itself.
local Threader = require(game:GetService("ReplicatedStorage").Threader)
local myThreader = Threader.new(5, PATH.TO.WORKER.MODULE)
Creating a ThreadWorker
A ThreadWorker is a ModuleScript that is used to process the data in all of the threads
once Threader:Dispatch() was called.
local myThreadWorker = Threader.ThreadWorker.new()
function myThreadWorker:OnDispatch(data)
return data
end
function myThreadWorker:OnCancel()
print("Cancelled!")
end
return myThreadWorker
Get the Data Back
Getting the data back from all of the threads is very simple! Since Threader is Promise based after calling Threader:Dispatch() a Promise will be returned that will resolve once all of the threads had completed or gets rejected if any error occurs!
Main script
local myThreader = Threader.new(5, script.MyThreadWorkerModule)
myThreader:Dispatch(table.create(1000, 1)):andThen(function(results)
print(results)
end)
ThreadWorker
local MyThreadWorker = Threader.ThreadWorker.new()
function MyThreadWorker:OnDispatch(data)
local sum = 0
for _, num in data do
sum += num
end
return sum
end
return MyThreadWorker
Package Details
Install command (Click to copy)
Version
1.0.1
License
MIT
Safe for commercial use
Automated license review — not legal advice.
