The Channel class also defines a method that checks on whether the channel is closed. This method is called closed.
my $c = Channel.new; say "open" if !$c.closed; # is openΒ $c.close; say "closed" if $c.closed; # closed
Despite the simplicity of using the method, it in fact returns not a simple Boolean value but a promise object (a variable of the Promise class). A promise (we will talk about this later) can be either kept or broken. Thus, if the channel is open, the closed promise is not yet kept; it is only given (or planned).
Promise.new(status => PromiseStatus::Planned, β¦)
After the channel is closed, the promise is kept.
Promise.new(status => PromiseStatus::Kept, β¦)
You can see the state of the promise above in its status field.