I am trying to understand the usage of @sync and @async macros in Julia. I am trying to get this MWE to work and the program does not terminate. Any help is appreciated.
function process_node(nodes, id)
@show id
sleep(1.0)
nodes[id] = true
return
end
function main()
nodes = Dict( i => false for i in 1:10 )
jobs = Channel{Int}(15)
for i in 1:10
put!(jobs, i)
end
@sync for id in jobs
@async process_node(nodes, id)
end
println("done")
end
main()
The program never gets to the line println("done")
. I do not know why.
Also, if you can point me to some reference or blog that has a tutorial for using co-routines without talking about any distributed programming, it would be great.
Thanks in advance.