148 posts
Posted 07 January 2015 - 07:11 PM
The title says it all. I want to make a table of functions that will be paralleled. Please help.
3057 posts
Location
United States of America
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.
227 posts
Location
Germany
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:
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.
148 posts
Posted 07 January 2015 - 08:16 PM
Thanks for the replys It worked