I tried to complete two tasks (coroutines) for collaboration, but to no avail. The following is what I have. I never see printlns from source or receiver functions, and the wait () call seems to hang forever. I also tried to make the p (source) task a global variable instead of passing it to sink () as an argument, but that doesn't work either (even if I declare it inside sinke () as global.
This is what I found that I can do very easily with channels and goroutines in Go.
I also experimented with calling yieldto () inside the source () and sink () functions, but I still seem to be ending the dead end.
Anyone who has an example of several tasks sharing data? Ideally, I would have a pipeline or a long chain of tasks.
Thanks in advance for your help.
println("Hello") function source() println("source start") produce("start") produce("stop") end function sink(p::Task) println("sink start") println(consume(p)) println(consume(p)) end a = Task( source ) b = Task( () -> sink(a) ) wait(b) wait(a) println("Goodbye")
coroutine task julia-lang
Richard Palmer
source share