Skip to content

Commit

Permalink
allow produce and consume to pass values in both directions. closes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Nov 19, 2013
1 parent 0e5f95b commit ca567b4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions base/task.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ function produce(v)
# make a task waiting for us runnable again
notify1(q)
end
yieldto(ct.last, v)
r = yieldto(ct.last, v)
ct.parent = ct.last # always exit to last consumer
nothing
r
end
produce(v...) = produce(v)

function consume(P::Task)
function consume(P::Task, values...)
while !(P.runnable || P.done)
if P.consumers === nothing
P.consumers = Condition()
Expand All @@ -65,7 +65,7 @@ function consume(P::Task)
ct = current_task()
prev = ct.last
ct.runnable = false
v = yieldto(P)
v = yieldto(P, values...)
ct.last = prev
ct.runnable = true
if P.done
Expand Down

0 comments on commit ca567b4

Please sign in to comment.