From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-3.0 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_MED,SPF_PASS,T_DKIM_INVALID, T_RP_MATCHES_RCVD shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id 2ADD520282 for ; Thu, 22 Jun 2017 07:23:48 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 641F0120793; Thu, 22 Jun 2017 16:23:43 +0900 (JST) Received: from o1678916x28.outbound-mail.sendgrid.net (o1678916x28.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id 9C8D8120755 for ; Thu, 22 Jun 2017 16:23:40 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=sendgrid.me; h=from:to:references:subject:mime-version:content-type:content-transfer-encoding:list-id; s=smtpapi; bh=OmYX9zfImAxOszJXxMDVBwp0Gec=; b=f/jHqK7TTydn8jJ1mi YtGAsr72hjzCjnfXWDtzN+/XJOxCCLueknnaWhLLbAzoEDp1FWsql/HnPgiRpd0x /g+m4JIfz6UB9DjNYM018O1X1Kh2/6KEL5UjIDPzc+bSisel5JsWvBYhpKyIbGGR yw7XT+WXkAKcl3R3RJrWRIWDE= Received: by filter1160p1mdw1.sendgrid.net with SMTP id filter1160p1mdw1-2399-594B7077-4 2017-06-22 07:23:35.128292477 +0000 UTC Received: from herokuapp.com (ec2-50-17-113-65.compute-1.amazonaws.com [50.17.113.65]) by ismtpd0003p1iad1.sendgrid.net (SG) with ESMTP id X3oIvY6FTEe40ah7N878Ag Thu, 22 Jun 2017 07:23:35.097 +0000 (UTC) Date: Thu, 22 Jun 2017 07:23:34 +0000 From: glass.saga@gmail.com To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 56766 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 9145 X-Redmine-Issue-Author: jsc X-Redmine-Sender: Glass_saga X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: ync6xU2WACa70kv/Ymy4QrNMhiuLXJG8OTL2vJD1yS4rAmYMO3gwJ5sw0sscBYfeif4iYlKNrSSerf qA3PY+qIquiPQzwM77B0RTx1UfQZx+kqkFWwe9a78pn5p3zQE6cxlByonw0mJsnsu6pfbAEb+cXuTO a1fie2tyI9gyr2DUDgX3NcABL5obWCLAec/7lRhSEsn+de3bckL1jmTxEA== X-ML-Name: ruby-core X-Mail-Count: 81738 Subject: [ruby-core:81738] [Ruby trunk Feature#9145][Closed] Queue#pop(true) return nil if empty instead of raising ThreadError X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" 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/