Skip to content

Commit

Permalink
fix #32575, channel trying to switch to task on another thread (#32584)
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson authored Jul 16, 2019
1 parent 9b987cc commit 80361a7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions base/channels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,8 @@ function put_unbuffered(c::Channel, v)
finally
unlock(c)
end
# unfair version of: schedule(taker, v); yield()
yield(taker, v) # immediately give taker a chance to run, but don't block the current task
schedule(taker, v)
yield() # immediately give taker a chance to run, but don't block the current task
return v
end

Expand Down
9 changes: 9 additions & 0 deletions test/threads_exec.jl
Original file line number Diff line number Diff line change
Expand Up @@ -665,3 +665,12 @@ let timeout = 300 # this test should take about 1-10 seconds
end
close(t) # stop the watchdog
end

# issue #32575
let ch = Channel{Char}(0), t
t = Task(()->for v in "hello" put!(ch, v) end)
t.sticky = false
bind(ch, t)
schedule(t)
@test String(collect(ch)) == "hello"
end

0 comments on commit 80361a7

Please sign in to comment.