Make Parallel Luau 2 Easier To Work With - ActorPool V4


Due to the release of Parallel Luau 2 I have decided to update my ActorPool module to support it.

Github Repo (And API Docs): GitHub - MightyPart/ActorPool_v4
Roblox Library: ActorPool - Roblox


With ActorPool you can easily run any module script in parallel. Take the following ModuleScript (called SumOfNums) for example:

return function(numsToAdd)
	local total = 0
	for _,num in numsToAdd do total += num end
	numsToAdd["total"] = total
end

You can run it in parallel easily using the following code:

local ActorPool = require(game:GetService("ReplicatedStorage").ActorPool)

local ParallelizedModule = ActorPool.quick(script.SumOfNums)

local NumsToAdd = SharedTable.new { 2, 4, 6, 8 }
ParallelizedModule(numsToAdd)
print(NumsToAdd["total"]) -- PRINTS: 20

If you want a more fine-grained control over your pool then you can use ActorPool.new instead of ActorPool.quick.

local ActorPool = require(game:GetService("ReplicatedStorage").ActorPool)

local myPool = ActorPool.new {
	baseModule = script.SumOfNums,
	poolFolder = script.Actors,
	min = 1,
	max = 2,
	retries = 10,
	retriesInterval = 0
}


local NumsToAdd = SharedTable.new { 2, 4, 6, 8 }
local myActorFromPool = myPool:take()
myActorFromPool:run(NumsToAdd)
print(NumsToAdd["total"]) -- PRINTS: 20
11 Likes