I am trying to make a simple and straightforward parallel processing module, however it doesn’t really seem to be working. I have created a debug profile, but, it doesn’t appear like things are running in parallel…
Here is the main module source :
local ACTOR_COUNT = 64
local actors = {}
do
local actor = script.Actor
table.insert(actors, actor)
for i = 1, ACTOR_COUNT - 1 do
local newActor = actor:Clone()
newActor.Parent = script
table.insert(actors, newActor)
end
end
local actorIndex = 1
return function(f, ...)
local actor = actors[actorIndex]
actorIndex = actorIndex % ACTOR_COUNT + 1
return actor.Function:Invoke(f, ...)
end
Here is the Actor Template Source :
local functions = require(script.Parent.Parent.Functions)
script.Parent.Function.OnInvoke = function(f, ...)
task.desynchronize()
debug.profilebegin("Test")
local a, b = 0, 1
for i = 1, 1e6 do a, b = b, a end
--local r = {functions[f](...)}
debug.profileend()
return {}, os.clock()
end
Here is the running script :
local pp = require(workspace.ParallelProcess)
while true do
for i = 1, 10 do
local t, s = pp("Test")
--print(os.clock() - s)
end
wait()
end