Function to check if Channel is full

The function isready(ch) checks if Channel ch has any stored value. Is there a function to check if a Channel is full?

There is no function in Base, but you can do it yourself:

isfull(ch::Channel) = length(ch.data) ≥ ch.sz_max

But be aware that isfull is also exported by DataStructures.

1 Like

This fixes the unbuffered channel case:

isfull(ch::Channel) = begin
    if ch.sz_max===0
        isready(ch)
    else
        length(ch.data) ≥ ch.sz_max
    end
end

1 Like