Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #32575, channel trying to switch to task on another thread #32584

Merged
merged 1 commit into from
Jul 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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