You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by tr...@apache.org on 2008/05/23 04:34:16 UTC

svn commit: r659370 - in /mina/branches/buffer/core/src/main/java/org/apache/mina/queue: AbstractIoQueue.java ByteBufferQueue.java QueueBackedIoQueue.java

Author: trustin
Date: Thu May 22 19:34:15 2008
New Revision: 659370

URL: http://svn.apache.org/viewvc?rev=659370&view=rev
Log:
Allowed AbstractIoQueue.doOffer() to return a boolean result value

Modified:
    mina/branches/buffer/core/src/main/java/org/apache/mina/queue/AbstractIoQueue.java
    mina/branches/buffer/core/src/main/java/org/apache/mina/queue/ByteBufferQueue.java
    mina/branches/buffer/core/src/main/java/org/apache/mina/queue/QueueBackedIoQueue.java

Modified: mina/branches/buffer/core/src/main/java/org/apache/mina/queue/AbstractIoQueue.java
URL: http://svn.apache.org/viewvc/mina/branches/buffer/core/src/main/java/org/apache/mina/queue/AbstractIoQueue.java?rev=659370&r1=659369&r2=659370&view=diff
==============================================================================
--- mina/branches/buffer/core/src/main/java/org/apache/mina/queue/AbstractIoQueue.java (original)
+++ mina/branches/buffer/core/src/main/java/org/apache/mina/queue/AbstractIoQueue.java Thu May 22 19:34:15 2008
@@ -117,7 +117,9 @@
             throw new RuntimeException("Failed to accept: " + e, t);
         }
 
-        doOffer(e);
+        if (!doOffer(e)) {
+            return false;
+        }
         offered(e);
         return true;
     }
@@ -140,7 +142,7 @@
      *
      * @param e an element to add to the tail of this queue.
      */
-    protected abstract void doOffer(E e);
+    protected abstract boolean doOffer(E e);
 
     /**
      * Performs the actual removal operation.

Modified: mina/branches/buffer/core/src/main/java/org/apache/mina/queue/ByteBufferQueue.java
URL: http://svn.apache.org/viewvc/mina/branches/buffer/core/src/main/java/org/apache/mina/queue/ByteBufferQueue.java?rev=659370&r1=659369&r2=659370&view=diff
==============================================================================
--- mina/branches/buffer/core/src/main/java/org/apache/mina/queue/ByteBufferQueue.java (original)
+++ mina/branches/buffer/core/src/main/java/org/apache/mina/queue/ByteBufferQueue.java Thu May 22 19:34:15 2008
@@ -22,6 +22,7 @@
 import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
 import java.util.NoSuchElementException;
+import java.util.Queue;
 
 /**
  * An {@link IoQueue} of {@link ByteBuffer}s.  {@link ByteBufferQueue} is
@@ -193,11 +194,11 @@
      * @return <tt>true</tt> if succeeded to transfer all bytes to the
      *         destination.  <tt>false</tt> if failed partially or entirely.
      */
-    boolean pollSlice(IoQueue<ByteBuffer> destination, int length);
+    boolean pollSlice(Queue<ByteBuffer> destination, int length);
 
     /**
      * Retrieves and removes the specified number of bytes from this queue.
-     * This method differs from {@link #pollSlice(IoQueue, int)} only
+     * This method differs from {@link #pollSlice(Queue, int)} only
      * in that it throws a {@link NoSuchElementException} when the length of
      * this queue is less than the specified length.
      *
@@ -210,7 +211,7 @@
      * @return <tt>true</tt> if succeeded to transfer all bytes to the
      *         destination.  <tt>false</tt> if failed partially or entirely.
      */
-    boolean removeSlice(IoQueue<ByteBuffer> destination, int length);
+    boolean removeSlice(Queue<ByteBuffer> destination, int length);
 
     /**
      * Retrieves, but does not remove, the specified number of bytes from this
@@ -222,11 +223,11 @@
      * @return <tt>true</tt> if succeeded to transfer all bytes to the
      *         destination.  <tt>false</tt> if failed partially or entirely.
      */
-    boolean peekSlice(IoQueue<ByteBuffer> destination, int length);
+    boolean peekSlice(Queue<ByteBuffer> destination, int length);
 
     /**
      * Retrieves, but does not remove, the specified number of bytes from this
-     * queue. This method differs from {@link #peekSlice(IoQueue, int)} only in
+     * queue. This method differs from {@link #peekSlice(Queue, int)} only in
      * that it throws a {@link NoSuchElementException} when the length of this
      * queue is less than the specified length.
      *
@@ -239,7 +240,7 @@
      * @return <tt>true</tt> if succeeded to transfer all bytes to the
      *         destination.  <tt>false</tt> if failed partially or entirely.
      */
-    boolean elementAsSlice(IoQueue<ByteBuffer> destination, int length);
+    boolean elementAsSlice(Queue<ByteBuffer> destination, int length);
 
     /**
      * Retrieves and removes one byte from the head of this queue.
@@ -431,7 +432,7 @@
      * @return <tt>true</tt> if succeeded to transfer all bytes to the
      *         destination.  <tt>false</tt> if failed partially or entirely.
      */
-    boolean getSlice(IoQueue<ByteBuffer> destination, int byteIndex, int length);
+    boolean getSlice(Queue<ByteBuffer> destination, int byteIndex, int length);
 
     /**
      * Merges all elements of this queue into one {@link ByteBuffer}.  This

Modified: mina/branches/buffer/core/src/main/java/org/apache/mina/queue/QueueBackedIoQueue.java
URL: http://svn.apache.org/viewvc/mina/branches/buffer/core/src/main/java/org/apache/mina/queue/QueueBackedIoQueue.java?rev=659370&r1=659369&r2=659370&view=diff
==============================================================================
--- mina/branches/buffer/core/src/main/java/org/apache/mina/queue/QueueBackedIoQueue.java (original)
+++ mina/branches/buffer/core/src/main/java/org/apache/mina/queue/QueueBackedIoQueue.java Thu May 22 19:34:15 2008
@@ -71,8 +71,8 @@
     }
 
     @Override
-    protected void doOffer(E e) {
-        q.offer(e);
+    protected boolean doOffer(E e) {
+        return q.offer(e);
     }
 
     @Override