Hello, I'm somewhat new to concurrent programming.

I'm trying to solve the consumer-producer problem 
<http://docs.julialang.org/en/latest/manual/control-flow/#tasks-aka-coroutines>,
 
making a another task to produce values and reading them in the main task. 
But the problem is that I want to produce values continuously while the 
main task does something else, for example:

solver = mytask() #returns immediately

while !done(solver)
    #Do something that can take minutes
    println(getsomething(solver)) #Print residual norm
end

So what is want from getsomething(solver) is the newest value and not the 
next value. The only way I found to do this was spawning (which is 
expensive) and using sleep() and a channel inside of the producer task, but 
this can behave erratically if other tasks are running.

Is there a way to make all tasks in the scheduler to take turns? Without 
having to make blocking calls on the main task, of course.


Reply via email to