From: Eric Wong Date: 2017-06-22T07:44:26+00:00 Subject: [ruby-core:81739] Re: [Ruby trunk Feature#9145][Closed] Queue#pop(true) return nil if empty instead of raising ThreadError glass.saga@gmail.com wrote: > Issue #9145 has been updated by Glass_saga (Masaki Matsushita). > > Status changed from Feedback to Closed > > Currently, Queue#pop takes non_block flag. No, I don't think this should be closed. I think Justin's point was: Currently, it is impossible to know if a queue is closed (permanent condition) or if it is empty (temporary condition). So at the very least, a different exception should be raised: Justin Collins wrote: > Alternatively, raise an exception that is a subclass of > ThreadError with a more specific name, such as "QueueEmpty". > This would be a small improvement while remaining compatible > with existing code. On a side note, relying on exceptions for flow control has all the same performance and $DEBUG noise problems it did with IO#*_nonblock [ruby-core:38666] [Feature #5138] But thinking of an efficient API for that is tricky :< Unsubscribe: