From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: poffice@blade.nagaokaut.ac.jp Delivered-To: poffice@blade.nagaokaut.ac.jp Received: from kankan.nagaokaut.ac.jp (kankan.nagaokaut.ac.jp [133.44.2.24]) by blade.nagaokaut.ac.jp (Postfix) with ESMTP id AADB619E0025 for ; Wed, 16 Dec 2015 02:20:41 +0900 (JST) Received: from voscc.nagaokaut.ac.jp (voscc.nagaokaut.ac.jp [133.44.1.100]) by kankan.nagaokaut.ac.jp (Postfix) with ESMTP id B4BE2B5D8B7 for ; Wed, 16 Dec 2015 02:52:42 +0900 (JST) Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by voscc.nagaokaut.ac.jp (Postfix) with ESMTP id 9925618CC7E4 for ; Wed, 16 Dec 2015 02:52:42 +0900 (JST) Received: from [221.186.184.76] (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 18C941204A0; Wed, 16 Dec 2015 02:52:42 +0900 (JST) X-Original-To: ruby-core@ruby-lang.org Delivered-To: ruby-core@ruby-lang.org Received: from o2.heroku.sendgrid.net (o2.heroku.sendgrid.net [67.228.50.55]) by neon.ruby-lang.org (Postfix) with ESMTPS id 436A4120496 for ; Wed, 16 Dec 2015 02:52:36 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sendgrid.me; h=from:to:references:subject:mime-version:content-type:content-transfer-encoding:list-id; s=smtpapi; bh=pMlMlESe39Ii5eR8M3n7QtVSws4=; b=lw/h6IDk3ij+yyWp1y nLWKRToJJddjTYkiHXcZCW3OvU59Z8Km9PRrvDiR4EQ8n3aGsERcomiCybEsSrQg 4+BH1M1fqcdFBQ7V8kXvRwsUZTVsyrzsSANGTXrsFC6KUM9XE+8nIXYLzBjAwkUH hjWvHQFwKjczTi02IQKbfypQ0= Received: by filter0811p1mdw1.sendgrid.net with SMTP id filter0811p1mdw1.19901.5670534728 2015-12-15 17:52:07.524140033 +0000 UTC Received: from herokuapp.com (ec2-107-20-1-215.compute-1.amazonaws.com [107.20.1.215]) by ismtpd0002p1iad1.sendgrid.net (SG) with ESMTP id _6NwuKX6Sz2gsb-l5TnHFg for ; Tue, 15 Dec 2015 17:52:07.706 +0000 (UTC) Date: Tue, 15 Dec 2015 17:52:07 +0000 From: headius@headius.com To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Redmine-MailingListIntegration-Message-Ids: 46862 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 11822 X-Redmine-Issue-Author: headius X-Redmine-Sender: headius 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/Ymy4QrNMhiuLXJG8OTL2vJD1yS5RIOGXCRl01IWPRnTv0pEiOJR5nzx95kP7kz bAdJZ1Ia6uhMX+khzYfiIugVG/UkMc7ymQUSUVA5XNPbXPySf34Qg9Gkr0LIp9GCPw5dFNspOFMgVM VRfqgbkWt8G0X/hfvJqCk68webKEp0PA0BzhbjYCMX1f7ElXCaET2vhAKA== X-ML-Name: ruby-core X-Mail-Count: 72155 Subject: [ruby-core:72155] [Ruby trunk - Bug #11822] Semantics of Queue#pop after close are wrong 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: , Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #11822 has been updated by Charles Nutter. Also worth noting that java.util.concurrent's BlockingQueue implementations do not support any of the following for the same reasons as above: * Closing or shutting down a queue * Notifying all threads waiting on a queue that it is no longer available The justification is that shutdown semantics for threads waiting on a queue varies too greatly to have a single consistent semantic. Some code will want a "closed" queue to cause all waiters to raise an error, others may want them to all receive a null value, still others will want them to receive a poison pill indicating the queue is done. Basically, the expectation is that if user code sets up threads to wait on a queue, user code should also handle notifying them that the queue is no longer available for use. I agree. ---------------------------------------- Bug #11822: Semantics of Queue#pop after close are wrong https://bugs.ruby-lang.org/issues/11822#change-55565 * Author: Charles Nutter * Status: Open * Priority: Normal * Assignee: * ruby -v: * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN ---------------------------------------- Current test/ruby/thread/test_queue.rb test_close has the following assertion that seems wrong to me: def test_close [->{Queue.new}, ->{SizedQueue.new 3}].each do |qcreate| q = qcreate.call assert_equal false, q.closed? q << :something assert_equal q, q.close assert q.closed? assert_raise_with_message(ClosedQueueError, /closed/){q << :nothing} assert_equal q.pop, :something # <<< THIS ONE assert_nil q.pop assert_nil q.pop # non-blocking assert_raise_with_message(ThreadError, /queue empty/){q.pop(non_block=true)} end end Once a queue is closed, I don't think it should ever return a result anymore. The queue should be cleared and pop should always return nil. In r52691, ko1 states that "deq'ing on closed queue returns nil, always." This test does not match that behavior. -- https://bugs.ruby-lang.org/