lib/async/channel.rb in grumlin-0.18.1 vs lib/async/channel.rb in grumlin-0.19.0

- old
+ new

@@ -16,10 +16,14 @@ def closed? @closed end + def open? + !@closed + end + # Methods for a publisher def <<(payload) raise(ChannelClosedError, "Cannot send to a closed channel") if @closed @queue << [:payload, payload] @@ -34,9 +38,16 @@ def close return if closed? @queue << [:close] @closed = true + end + + def close! + return if closed? + + exception(ChannelClosedError.new("Channel was forcefully closed")) + close end # Methods for a subscriber def dequeue each do |payload| # rubocop:disable Lint/UnreachableLoop this is intended