Return-Path: X-Original-To: apmail-river-dev-archive@www.apache.org Delivered-To: apmail-river-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id F11B09B12 for ; Fri, 23 Sep 2011 09:28:06 +0000 (UTC) Received: (qmail 67354 invoked by uid 500); 23 Sep 2011 09:28:06 -0000 Delivered-To: apmail-river-dev-archive@river.apache.org Received: (qmail 67294 invoked by uid 500); 23 Sep 2011 09:28:06 -0000 Mailing-List: contact dev-help@river.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@river.apache.org Delivered-To: mailing list dev@river.apache.org Received: (qmail 67282 invoked by uid 99); 23 Sep 2011 09:28:06 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 23 Sep 2011 09:28:06 +0000 X-ASF-Spam-Status: No, hits=4.0 required=5.0 tests=HTML_MESSAGE,MISSING_MIMEOLE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [207.57.65.70] (HELO zeus.net.au) (207.57.65.70) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 23 Sep 2011 09:27:58 +0000 Received: (qmail 19841 invoked by uid 16710); 23 Sep 2011 09:27:37 -0000 Received: from unknown (HELO [106.70.197.160]) ([106.70.197.160]) (envelope-sender ) by 207.57.65.70 (qmail-ldap-1.03) with SMTP for ; 23 Sep 2011 09:27:37 -0000 From: Peter Reply-To: Peter To: dev@river.apache.org Subject: Soft reference blocking queue X-Mailer: Modest 3.1 Content-Type: multipart/alternative; boundary="=-rmvwpsmTVvRHBTuuSX+C" X-MSMail-Priority: Normal X-Priority: 3 Date: Fri, 23 Sep 2011 19:29:18 +1000 Message-Id: <1316770158.11253.5.camel@Nokia-N900-51-1> Mime-Version: 1.0 --=-rmvwpsmTVvRHBTuuSX+C Content-Type: text/plain; charset=utf-8 Content-ID: <1316770157.11253.2.camel@Nokia-N900-51-1> Content-Transfer-Encoding: 7bit Just pondering if there's a use case for weak or soft references in a blocking queue. I was writing a unit test for it today. One use case might be around cancelled future tasks with an executor, you just null out any strong references, if it hasn't yet executed it probably won't. Eg future has timed out, null out reference and it is removed from the queue by garbage collection. This might help to keep a queue small when there are a large number of tasks being cancelled before they execute, rather than occupying memory in the queue between other tasks awaiting execution. The other case might be an unbounded queue, with a single thread taking, it blocks waiting for data, instead of the queue causing a memory explosion when it can't handle the data given to it , it just starts dropping objects, a bit like a network reciever. The sender can retry later. Cheers, Peter. --=-rmvwpsmTVvRHBTuuSX+C--