From: glass.saga@gmail.com
To: ruby-core@ruby-lang.org
Subject: [ruby-core:81738] [Ruby trunk Feature#9145][Closed] Queue#pop(true) return nil if empty instead of raising ThreadError
Date: Thu, 22 Jun 2017 07:23:34 +0000 [thread overview]
Message-ID: <redmine.journal-65440.20170622072334.2cc3679c55b01450@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-9145.20131124124225@ruby-lang.org
Issue #9145 has been updated by Glass_saga (Masaki Matsushita).
Status changed from Feedback to Closed
Currently, Queue#pop takes non_block flag.
----------------------------------------
Feature #9145: Queue#pop(true) return nil if empty instead of raising ThreadError
https://bugs.ruby-lang.org/issues/9145#change-65440
* Author: jsc (Justin Collins)
* Status: Closed
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
I propose the non-blocking form of Queue#pop behave like Array#pop and return nil when empty.
Current behavior is to raise a ThreadError, with a message indicating the queue is empty.
For example:
q = Queue.new
begin
loop do
next_item = q.pop(true)
end
rescue ThreadError
# queue is empty...or maybe something bad happened
end
Instead, this could be
q = Queue.new
while next_item = q.pop(true)
end
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.
--
https://bugs.ruby-lang.org/
next prev parent reply other threads:[~2017-06-22 7:23 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-24 3:42 [ruby-core:58545] [ruby-trunk - Feature #9145][Open] Queue#pop(true) return nil if empty instead of raising ThreadError jsc (Justin Collins)
2013-11-24 4:30 ` [ruby-core:58546] [ruby-trunk - Feature #9145][Feedback] " Glass_saga (Masaki Matsushita)
2013-11-24 4:42 ` [ruby-core:58547] " Eric Wong
2013-11-25 2:55 ` [ruby-core:58562] " Joel VanderWerf
2013-11-25 0:13 ` [ruby-core:58556] [ruby-trunk - Feature #9145] " jsc (Justin Collins)
2013-11-25 6:17 ` [ruby-core:58564] " drbrain (Eric Hodel)
2017-06-22 7:23 ` glass.saga [this message]
2017-06-22 7:44 ` [ruby-core:81739] Re: [Ruby trunk Feature#9145][Closed] " Eric Wong
2018-01-01 19:41 ` [ruby-core:84576] [Ruby trunk Feature#9145] " uwe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.ruby-lang.org/en/community/mailing-lists/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=redmine.journal-65440.20170622072334.2cc3679c55b01450@ruby-lang.org \
--to=ruby-core@ruby-lang.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).