Wow thanks so much for this and your other posts on recursion.
Originally I used @async
and Ref
to break the loop with an external command. However the warning in the docs encouraged the use of @spawn over @async. Am I correct in understanding that in cases involving the parallel mutation of arrays @async
is still preferable over @spawn
becuase it disables the migration of the parent task across worker threads?
With a while loop it seems like breaking the loop with an external command becomes more periphrastic than using tail end recursion. Something like
function main(testpop, cont = Ref(true))
@async while all(!isempty,testpop) && cont[]
for group in testpop
condition = second(now())/10
@async for people in group
cont [] || break
if condition <= rand(1:12)
break
else
fun1(people)
popfirst!(group)
end
end
return(cont)
end
end
return(cont)
end
When you mention in this post that
Did you mean that there are meaningful disadvantages to tail end recursion in julia? Or is it just bad practice in general?