Behavior of isready on unbuffered Channel

Hello,

The documentation for Base.isready says that the function returns true if there are tasks waiting on a put!.

However, on Julia 1.8 I tried this:

function unbuffered_channel_test()

    channel = Channel{Int64}()

    @async begin
        for _ in 1:2
            println("Waiting on Channel")
            v = take!(channel);
            println("Got $v")
        end
        println("Done")
    end

    sleep(1)
    @show isready(channel)
    put!(channel, 7)
    sleep(1)
    @show isready(channel)
    put!(channel, 11)

end

And I’m getting this:

julia> unbuffered_channel_test();
Waiting on Channel
isready(channel) = false
Got 7
Waiting on Channel      
isready(channel) = false
Got 11
Done

Shouldn’t isready return true while the consumer task is blocked on the take!? Am I misunderstanding something?

Thanks!

I think you are reading the documentation wrong. I take " Determine whether a Channel has a value stored to it., an isreadyin general, means that the channel is ready to be read, not that it is ready to be written to. Specifically, "For unbuffered channels returnstrue if there are tasks waiting on a [put!]" sounds like a take!` won’t block.

You’re absolutely right. I interpreted the phrase “there are tasks waiting on a put!” as “Tasks are blocked waiting for another to put! something in the Channel”. But it actually means “the putting Task is blocked waiting for another to take! from the Channel”. Which, like you said, is consistent with the behavior for a buffered Channel.