Skip to content

Modern Chan Channel IsClosed

Paul Squires edited this page Oct 19, 2026 · 5 revisions

Home › Goroutines and Channels › Goroutines and Channels › IsClosed

IsClosed

Returns true once the channel is closed, even while values are still buffered.

Syntax

IsClosed( ) as boolean

Notes

  • It is what tells a FALSE from TryReceive apart: "nothing right now" versus "nothing ever again".
  • TRUE while buffered values remain -- closed and drained are different states, and Receive keeps yielding until both hold.
  • A snapshot. Do not branch on it to decide whether a Send will succeed; check the result of the send.

Examples

#import "std/tasks"
using tasks

dim ch as Channel( of int32 ) = Channel( of int32 )( 4 )
print ch.IsClosed( )         '' false

dim as int32 v = 1
ch.Send( v )
ch.Close( )

'' TRUE even though a value is still buffered: closed and drained are
'' two different things
print ch.IsClosed( )         '' true
print ch.Count( )            '' 1

Library: Goroutines and Channels
Category: Goroutines and Channels
Documented under: Members

Clone this wiki locally