commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1506481 - in /commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl: LinkedBlockingDeque.java PooledObject.java
Date Wed, 24 Jul 2013 10:23:01 GMT
Author: markt
Date: Wed Jul 24 10:23:01 2013
New Revision: 1506481

URL: http://svn.apache.org/r1506481
Log:
Decouple PooledObject from the Deque implementation (required for some refactoring to follow)

Modified:
    commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/LinkedBlockingDeque.java
    commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/PooledObject.java

Modified: commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/LinkedBlockingDeque.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/LinkedBlockingDeque.java?rev=1506481&r1=1506480&r2=1506481&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/LinkedBlockingDeque.java
(original)
+++ commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/LinkedBlockingDeque.java
Wed Jul 24 10:23:01 2013
@@ -16,8 +16,10 @@
  */
 package org.apache.commons.pool2.impl;
 
+import java.io.Serializable;
 import java.util.AbstractQueue;
 import java.util.Collection;
+import java.util.Deque;
 import java.util.Iterator;
 import java.util.NoSuchElementException;
 import java.util.concurrent.TimeUnit;
@@ -55,7 +57,7 @@ import java.util.concurrent.locks.Reentr
  *       Commons Pool.
  */
 class LinkedBlockingDeque<E> extends AbstractQueue<E>
-        implements java.io.Serializable {
+        implements Deque<E>, Serializable {
 
     /*
      * Implemented as a simple doubly-linked list protected by a
@@ -303,6 +305,7 @@ class LinkedBlockingDeque<E> extends Abs
      * @throws IllegalStateException
      * @throws NullPointerException
      */
+    @Override
     public void addFirst(E e) {
         if (!offerFirst(e))
             throw new IllegalStateException("Deque full");
@@ -312,6 +315,7 @@ class LinkedBlockingDeque<E> extends Abs
      * @throws IllegalStateException
      * @throws NullPointerException
      */
+    @Override
     public void addLast(E e) {
         if (!offerLast(e))
             throw new IllegalStateException("Deque full");
@@ -320,6 +324,7 @@ class LinkedBlockingDeque<E> extends Abs
     /**
      * @throws NullPointerException
      */
+    @Override
     public boolean offerFirst(E e) {
         if (e == null) throw new NullPointerException();
         final ReentrantLock lock = this.lock;
@@ -334,6 +339,7 @@ class LinkedBlockingDeque<E> extends Abs
     /**
      * @throws NullPointerException
      */
+    @Override
     public boolean offerLast(E e) {
         if (e == null) throw new NullPointerException();
         final ReentrantLock lock = this.lock;
@@ -424,6 +430,7 @@ class LinkedBlockingDeque<E> extends Abs
     /**
      * @throws NoSuchElementException
      */
+    @Override
     public E removeFirst() {
         E x = pollFirst();
         if (x == null) throw new NoSuchElementException();
@@ -433,12 +440,14 @@ class LinkedBlockingDeque<E> extends Abs
     /**
      * @throws NoSuchElementException
      */
+    @Override
     public E removeLast() {
         E x = pollLast();
         if (x == null) throw new NoSuchElementException();
         return x;
     }
 
+    @Override
     public E pollFirst() {
         final ReentrantLock lock = this.lock;
         lock.lock();
@@ -449,6 +458,7 @@ class LinkedBlockingDeque<E> extends Abs
         }
     }
 
+    @Override
     public E pollLast() {
         final ReentrantLock lock = this.lock;
         lock.lock();
@@ -524,6 +534,7 @@ class LinkedBlockingDeque<E> extends Abs
     /**
      * @throws NoSuchElementException
      */
+    @Override
     public E getFirst() {
         E x = peekFirst();
         if (x == null) throw new NoSuchElementException();
@@ -533,12 +544,14 @@ class LinkedBlockingDeque<E> extends Abs
     /**
      * @throws NoSuchElementException
      */
+    @Override
     public E getLast() {
         E x = peekLast();
         if (x == null) throw new NoSuchElementException();
         return x;
     }
 
+    @Override
     public E peekFirst() {
         final ReentrantLock lock = this.lock;
         lock.lock();
@@ -549,6 +562,7 @@ class LinkedBlockingDeque<E> extends Abs
         }
     }
 
+    @Override
     public E peekLast() {
         final ReentrantLock lock = this.lock;
         lock.lock();
@@ -559,6 +573,7 @@ class LinkedBlockingDeque<E> extends Abs
         }
     }
 
+    @Override
     public boolean removeFirstOccurrence(Object o) {
         if (o == null) return false;
         final ReentrantLock lock = this.lock;
@@ -576,6 +591,7 @@ class LinkedBlockingDeque<E> extends Abs
         }
     }
 
+    @Override
     public boolean removeLastOccurrence(Object o) {
         if (o == null) return false;
         final ReentrantLock lock = this.lock;
@@ -747,6 +763,7 @@ class LinkedBlockingDeque<E> extends Abs
      * @throws IllegalStateException
      * @throws NullPointerException
      */
+    @Override
     public void push(E e) {
         addFirst(e);
     }
@@ -754,6 +771,7 @@ class LinkedBlockingDeque<E> extends Abs
     /**
      * @throws NoSuchElementException
      */
+    @Override
     public E pop() {
         return removeFirst();
     }
@@ -1007,6 +1025,7 @@ class LinkedBlockingDeque<E> extends Abs
      * construction of the iterator, and may (but is not guaranteed to)
      * reflect any modifications subsequent to construction.
      */
+    @Override
     public Iterator<E> descendingIterator() {
         return new DescendingItr();
     }

Modified: commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/PooledObject.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/PooledObject.java?rev=1506481&r1=1506480&r2=1506481&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/PooledObject.java
(original)
+++ commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/PooledObject.java
Wed Jul 24 10:23:01 2013
@@ -19,6 +19,7 @@ package org.apache.commons.pool2.impl;
 import java.io.PrintWriter;
 import java.text.SimpleDateFormat;
 import java.util.Date;
+import java.util.Deque;
 
 /**
  * This wrapper is used to track the additional information, such as state, for
@@ -47,7 +48,7 @@ public class PooledObject<T> implements 
         createdBy = null;
         logWriter = null;
     }
-    
+
     public PooledObject(T object, PrintWriter logWriter) {
         this.object = object;
         this.logWriter = logWriter;
@@ -103,14 +104,14 @@ public class PooledObject<T> implements 
     public long getLastReturnTime() {
         return lastReturnTime;
     }
-    
+
     /**
      * Return an estimate of the last time this object was used.  If the class
-     * of the pooled object implements {@link TrackedUse}, what is returned is 
+     * of the pooled object implements {@link TrackedUse}, what is returned is
      * the maximum of {@link TrackedUse#getLastUsed()} and
      * {@link #getLastBorrowTime()}; otherwise this method gives the same
      * value as {@link #getLastBorrowTime()}.
-     * 
+     *
      * @return the last time this object was used
      */
     public long getLastUsed() {
@@ -184,7 +185,7 @@ public class PooledObject<T> implements 
     }
 
     public synchronized boolean endEvictionTest(
-            LinkedBlockingDeque<PooledObject<T>> idleQueue) {
+            Deque<PooledObject<T>> idleQueue) {
         if (state == PooledObjectState.EVICTION) {
             state = PooledObjectState.IDLE;
             return true;
@@ -241,7 +242,7 @@ public class PooledObject<T> implements 
     public synchronized void invalidate() {
         state = PooledObjectState.INVALID;
     }
-    
+
     /**
      * Prints the stack trace of the code that created this pooled object to
      * the configured log writer.  Does nothing of no PrintWriter was supplied
@@ -252,7 +253,7 @@ public class PooledObject<T> implements 
             createdBy.printStackTrace(logWriter);
         }
     }
-    
+
     /**
      * Returns the state of this object.
      * @return state
@@ -260,21 +261,21 @@ public class PooledObject<T> implements 
     public synchronized PooledObjectState getState() {
         return state;
     }
-    
+
     /**
      * Marks the pooled object as abandoned.
      */
     public synchronized void markAbandoned() {
         state = PooledObjectState.ABANDONED;
     }
-    
+
     /**
      * Marks the object as returning to the pool.
      */
     public synchronized void markReturning() {
         state = PooledObjectState.RETURNING;
     }
-    
+
     static class AbandonedObjectException extends Exception {
 
         private static final long serialVersionUID = 7398692158058772916L;



Mime
View raw message