Return-Path: Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: (qmail 21460 invoked from network); 15 Sep 2009 05:55:50 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 15 Sep 2009 05:55:50 -0000 Received: (qmail 8475 invoked by uid 500); 15 Sep 2009 05:55:49 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 8396 invoked by uid 500); 15 Sep 2009 05:55:49 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 8357 invoked by uid 99); 15 Sep 2009 05:55:49 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 Sep 2009 05:55:49 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 Sep 2009 05:55:45 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 61B1923889EC; Tue, 15 Sep 2009 05:54:28 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r815028 - /commons/proper/collections/trunk/src/java/org/apache/commons/collections/buffer/BlockingBuffer.java Date: Tue, 15 Sep 2009 05:54:28 -0000 To: commits@commons.apache.org From: bayard@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090915055428.61B1923889EC@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: bayard Date: Tue Sep 15 05:54:27 2009 New Revision: 815028 URL: http://svn.apache.org/viewvc?rev=815028&view=rev Log: Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified; mostly in r738956. Also see the following revisions: ------------------------------------------------------------------------ r814050 | sebb | 2009-09-11 15:01:25 -0700 (Fri, 11 Sep 2009) | 1 line Some minor Javadoc fixes ------------------------------------------------------------------------ r471579 | scolebourne | 2006-11-05 16:14:58 -0800 (Sun, 05 Nov 2006) | 1 line Generify, remove getBuffer() - use covariant decorated() ------------------------------------------------------------------------ Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/buffer/BlockingBuffer.java Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/buffer/BlockingBuffer.java URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/buffer/BlockingBuffer.java?rev=815028&r1=815027&r2=815028&view=diff ============================================================================== --- commons/proper/collections/trunk/src/java/org/apache/commons/collections/buffer/BlockingBuffer.java (original) +++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/buffer/BlockingBuffer.java Tue Sep 15 05:54:27 2009 @@ -45,10 +45,11 @@ * @author Janek Bogucki * @author Phil Steitz * @author James Carman + * @param the type of the elements in the buffer * @version $Revision$ $Date$ * @since Commons Collections 3.0 */ -public class BlockingBuffer extends SynchronizedBuffer { +public class BlockingBuffer extends SynchronizedBuffer { /** Serialization version. */ private static final long serialVersionUID = 1719328905017860541L; @@ -58,25 +59,27 @@ /** * Factory method to create a blocking buffer. * + * @param the type of the elements in the buffer * @param buffer the buffer to decorate, must not be null * @return a new blocking Buffer * @throws IllegalArgumentException if buffer is null */ - public static Buffer decorate(Buffer buffer) { - return new BlockingBuffer(buffer); + public static Buffer decorate(Buffer buffer) { + return new BlockingBuffer(buffer); } /** * Factory method to create a blocking buffer with a timeout value. * + * @param the type of the elements in the buffer * @param buffer the buffer to decorate, must not be null * @param timeoutMillis the timeout value in milliseconds, zero or less for no timeout * @return a new blocking buffer * @throws IllegalArgumentException if the buffer is null * @since Commons Collections 3.2 */ - public static Buffer decorate(Buffer buffer, long timeoutMillis) { - return new BlockingBuffer(buffer, timeoutMillis); + public static Buffer decorate(Buffer buffer, long timeoutMillis) { + return new BlockingBuffer(buffer, timeoutMillis); } //----------------------------------------------------------------------- @@ -86,7 +89,7 @@ * @param buffer the buffer to decorate, must not be null * @throws IllegalArgumentException if the buffer is null */ - protected BlockingBuffer(Buffer buffer) { + protected BlockingBuffer(Buffer buffer) { super(buffer); this.timeout = 0; } @@ -99,13 +102,13 @@ * @throws IllegalArgumentException if the buffer is null * @since Commons Collections 3.2 */ - protected BlockingBuffer(Buffer buffer, long timeoutMillis) { + protected BlockingBuffer(Buffer buffer, long timeoutMillis) { super(buffer); this.timeout = (timeoutMillis < 0 ? 0 : timeoutMillis); } //----------------------------------------------------------------------- - public boolean add(Object o) { + public boolean add(E o) { synchronized (lock) { boolean result = collection.add(o); lock.notifyAll(); @@ -113,7 +116,7 @@ } } - public boolean addAll(Collection c) { + public boolean addAll(Collection c) { synchronized (lock) { boolean result = collection.addAll(c); lock.notifyAll(); @@ -128,7 +131,7 @@ * * @throws BufferUnderflowException if an interrupt is received */ - public Object get() { + public E get() { synchronized (lock) { while (collection.isEmpty()) { try { @@ -143,7 +146,7 @@ throw new BufferUnderflowException("Caused by InterruptedException: " + out.toString()); } } - return getBuffer().get(); + return decorated().get(); } } @@ -156,7 +159,7 @@ * @throws BufferUnderflowException if the timeout expires * @since Commons Collections 3.2 */ - public Object get(final long timeout) { + public E get(final long timeout) { synchronized (lock) { final long expiration = System.currentTimeMillis() + timeout; long timeLeft = expiration - System.currentTimeMillis(); @@ -173,7 +176,7 @@ if (collection.isEmpty()) { throw new BufferUnderflowException("Timeout expired"); } - return getBuffer().get(); + return decorated().get(); } } @@ -184,7 +187,7 @@ * * @throws BufferUnderflowException if an interrupt is received */ - public Object remove() { + public E remove() { synchronized (lock) { while (collection.isEmpty()) { try { @@ -199,7 +202,7 @@ throw new BufferUnderflowException("Caused by InterruptedException: " + out.toString()); } } - return getBuffer().remove(); + return decorated().remove(); } } @@ -212,7 +215,7 @@ * @throws BufferUnderflowException if the timeout expires * @since Commons Collections 3.2 */ - public Object remove(final long timeout) { + public E remove(final long timeout) { synchronized (lock) { final long expiration = System.currentTimeMillis() + timeout; long timeLeft = expiration - System.currentTimeMillis(); @@ -229,7 +232,7 @@ if (collection.isEmpty()) { throw new BufferUnderflowException("Timeout expired"); } - return getBuffer().remove(); + return decorated().remove(); } }