diff --git a/base/channels.jl b/base/channels.jl index 1557504bbe21e..5fb09f38f7a01 100644 --- a/base/channels.jl +++ b/base/channels.jl @@ -416,6 +416,11 @@ immediately, does not block. For unbuffered channels returns `true` if there are tasks waiting on a [`put!`](@ref). + +!!! warning + This function isn't threadsafe. For multithreaded code, use it inside a + block of code which is synchronized with `lock(c)` to avoid race + conditions. """ isready(c::Channel) = n_avail(c) > 0 n_avail(c::Channel) = isbuffered(c) ? length(c.data) : length(c.cond_put.waitq) @@ -427,7 +432,6 @@ unlock(c::Channel) = unlock(c.cond_take) trylock(c::Channel) = trylock(c.cond_take) function wait(c::Channel) - isready(c) && return lock(c) try while !isready(c) diff --git a/base/condition.jl b/base/condition.jl index be0f618865a48..ce725823dc3b5 100644 --- a/base/condition.jl +++ b/base/condition.jl @@ -79,7 +79,6 @@ lock(f, c::GenericCondition) = lock(f, c.lock) # have waiter wait for c function _wait2(c::GenericCondition, waiter::Task) - ct = current_task() assert_havelock(c) push!(c.waitq, waiter) return