Parallel Lua Beta

Hi!
A question, is it possible to do this pattern?

HeartBeat on main thread → Fire off 100 actors do some work using BindableEvents and ConnectParallel
HeartBeat on main thread → Suspends (not waits) until the actors are all finished

My initial idea would be something like:

local count = 0
callback = Instance.new("BindableEvent")
callback.Invoke:Connect(function(results)
   count-=1
end)


for _,actorEvent in pairs(actors) do
   actorEvent:Fire(work, callback)
   count+=1
end

--somehow suspend, not wait, until count = 0?

(and the actor would just call callback:Fire() in its own bindable event )

1 Like