# Function to check if Channel is full

**URL:** <https://discourse.julialang.org/t/function-to-check-if-channel-is-full/44795>\
**Category:** New to Julia\
**Created:** [August 12, 2020, 9:28am UTC](https://discourse.julialang.org/t/function-to-check-if-channel-is-full/44795 "2020-08-12T09:28:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![martincornejo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/martincornejo/32/13436_2.png) [@martincornejo](https://discourse.julialang.org/u/martincornejo)\
**Post date:** [August 12, 2020, 9:28am UTC](https://discourse.julialang.org/t/function-to-check-if-channel-is-full/44795/1 "2020-08-12T09:28:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pbayer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pbayer/32/11675_2.png) [@pbayer](https://discourse.julialang.org/u/pbayer)\
**Post date:** [August 12, 2020, 10:43am UTC](https://discourse.julialang.org/t/function-to-check-if-channel-is-full/44795/2 "2020-08-12T10:43:41Z")

</div>

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

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

```

But be aware that `isfull` is also exported by `DataStructures`.

---

<div class="post-metadata">

**Author:** ![attdona](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/attdona/32/15859_2.png) [@attdona](https://discourse.julialang.org/u/attdona)\
**Post date:** [April 27, 2022, 5:11am UTC](https://discourse.julialang.org/t/function-to-check-if-channel-is-full/44795/3 "2022-04-27T05:11:31Z")

</div>

This fixes the unbuffered channel case:

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

```

---

<div class="post-metadata">

**Author:** ![TheLateKronos](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thelatekronos/32/12824_2.png) [@TheLateKronos](https://discourse.julialang.org/u/TheLateKronos)\
**Post date:** [February 2, 2024, 1:24pm UTC](https://discourse.julialang.org/t/function-to-check-if-channel-is-full/44795/4 "2024-02-02T13:24:59Z")

</div>

I have given a go at implementing `isfull` in [Implement and export `isfull` by KronosTheLate · Pull Request #53159 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/pull/53159), which might be included from Julia 1.11 and onwards.
