You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by pr...@apache.org on 2006/04/28 19:45:08 UTC

svn commit: r397966 - /directory/trunks/mina/core/src/main/java/org/apache/mina/common/PooledByteBufferAllocator.java

Author: proyal
Date: Fri Apr 28 10:45:07 2006
New Revision: 397966

URL: http://svn.apache.org/viewcvs?rev=397966&view=rev
Log:
Do not pool containers. This is just simple object pooling, which is not necessary in modern JVMs

Modified:
    directory/trunks/mina/core/src/main/java/org/apache/mina/common/PooledByteBufferAllocator.java

Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/common/PooledByteBufferAllocator.java
URL: http://svn.apache.org/viewcvs/directory/trunks/mina/core/src/main/java/org/apache/mina/common/PooledByteBufferAllocator.java?rev=397966&r1=397965&r2=397966&view=diff
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/common/PooledByteBufferAllocator.java (original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/common/PooledByteBufferAllocator.java Fri Apr 28 10:45:07 2006
@@ -18,6 +18,8 @@
  */
 package org.apache.mina.common;
 
+import org.apache.mina.util.ExpiringStack;
+
 import java.nio.ByteOrder;
 import java.nio.CharBuffer;
 import java.nio.DoubleBuffer;
@@ -26,8 +28,6 @@
 import java.nio.LongBuffer;
 import java.nio.ShortBuffer;
 
-import org.apache.mina.util.ExpiringStack;
-
 /**
  * A {@link ByteBufferAllocator} which pools allocated buffers.
  * <p>
@@ -52,7 +52,6 @@
     private static int threadId = 0;
 
     private final Expirer expirer;
-    private final ExpiringStack containerStack = new ExpiringStack();
     private final ExpiringStack[] heapBufferStacks = new ExpiringStack[] {
             new ExpiringStack(), new ExpiringStack(), new ExpiringStack(),
             new ExpiringStack(), new ExpiringStack(), new ExpiringStack(),
@@ -110,11 +109,7 @@
         }
 
         expirer.shutdown();
-        synchronized( containerStack )
-        {
-            containerStack.clear();
-        }
-        
+
         for( int i = directBufferStacks.length - 1; i >= 0; i -- )
         {
             ExpiringStack stack = directBufferStacks[i];
@@ -181,17 +176,7 @@
 
     private PooledByteBuffer allocateContainer()
     {
-        PooledByteBuffer buf;
-        synchronized( containerStack )
-        {
-            buf = ( PooledByteBuffer ) containerStack.pop();
-        }
-        
-        if( buf == null )
-        {
-            buf = new PooledByteBuffer();
-        }
-        return buf;
+		return new PooledByteBuffer();
     }
     
     private UnexpandableByteBuffer allocate0( int capacity, boolean direct )
@@ -271,7 +256,7 @@
     {
         private boolean timeToStop;
 
-        public Expirer()
+        Expirer()
         {
             super( "PooledByteBufferExpirer-" + threadId++ );
             setDaemon( true );
@@ -289,6 +274,7 @@
                 }
                 catch ( InterruptedException e )
                 {
+                    //ignore since this is shutdown time
                 }
             }
         }
@@ -304,6 +290,7 @@
                 }
                 catch ( InterruptedException e )
                 {
+                    //ignore
                 }
 
                 // Check if expiration is disabled.
@@ -315,11 +302,7 @@
 
                 // Expire old buffers
                 long expirationTime = System.currentTimeMillis() - timeout;
-                synchronized( containerStack )
-                {
-                    containerStack.expireBefore( expirationTime );
-                }
-                
+
                 for( int i = directBufferStacks.length - 1; i >= 0; i -- )
                 {
                     ExpiringStack stack = directBufferStacks[ i ];
@@ -398,11 +381,6 @@
             }
 
             buf.release();
-
-            synchronized( containerStack )
-            {
-                containerStack.push( this );
-            }
         }
 
         public java.nio.ByteBuffer buf()