The title says it all. I want to make a table of functions that will be paralleled. Please help.
How do I Parallel functions inside table?
Started by CCGrimHaxor, Jan 07 2015 07:11 PM
3 replies to this topic
#1
Posted 07 January 2015 - 07:11 PM
#2
Posted 07 January 2015 - 07:15 PM
You could unpack() the table into the parallel call, other than that you can write your own parallel script using coroutines.
parallel source code.
parallel source code.
#3
Posted 07 January 2015 - 07:20 PM
You could either go the 'manual' way of doing it with coroutines, but you could also use parallel - if that fits your needs.
For example:
The sleep( 0 ) is just there to let parallel switch between the functions, as it has to wait for one function to yield before the other one can be executed.
For example:
local functions = {
function()
for i = 1, 5 do
print( "hello" )
sleep( 0 )
end
end;
function()
for i = 1, 5 do
print( i )
sleep( 0 )
end
end;
}
parallel.waitForAll( unpack( functions ) )
The sleep( 0 ) is just there to let parallel switch between the functions, as it has to wait for one function to yield before the other one can be executed.
#4
Posted 07 January 2015 - 08:16 PM
Thanks for the replys It worked
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











