directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r325860 - in /directory/network: branches/0.7/src/java/org/apache/mina/util/BaseThreadPool.java trunk/src/java/org/apache/mina/filter/ThreadPoolFilter.java
Date Mon, 17 Oct 2005 08:36:25 GMT
Author: trustin
Date: Mon Oct 17 01:36:09 2005
New Revision: 325860

URL: http://svn.apache.org/viewcvs?rev=325860&view=rev
Log:
Resolved issue: DIRMINA-95
* Got rid of unnessary null/emptiness check
* Renamed readySessionBuffers to unfetchedSessionBuffers
* Renamed busySessionBuffers to allSessionBuffers


Modified:
    directory/network/branches/0.7/src/java/org/apache/mina/util/BaseThreadPool.java
    directory/network/trunk/src/java/org/apache/mina/filter/ThreadPoolFilter.java

Modified: directory/network/branches/0.7/src/java/org/apache/mina/util/BaseThreadPool.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/0.7/src/java/org/apache/mina/util/BaseThreadPool.java?rev=325860&r1=325859&r2=325860&view=diff
==============================================================================
--- directory/network/branches/0.7/src/java/org/apache/mina/util/BaseThreadPool.java (original)
+++ directory/network/branches/0.7/src/java/org/apache/mina/util/BaseThreadPool.java Mon Oct
17 01:36:09 2005
@@ -82,8 +82,8 @@
     private final String threadNamePrefix;
     private final Map buffers = new IdentityHashMap();
     private final Stack followers = new Stack();
-    private final BlockingSet readySessionBuffers = new BlockingSet();
-    private final Set busySessionBuffers = new HashSet();
+    private final BlockingSet unfetchedSessionBuffers = new BlockingSet();
+    private final Set allSessionBuffers = new HashSet();
 
     private Worker leader;
 
@@ -215,11 +215,11 @@
     protected void fireEvent( Object nextFilter, Session session,
                               EventType type, Object data )
     {
-        final BlockingSet readySessionBuffers = this.readySessionBuffers;
-        final Set busySessionBuffers = this.busySessionBuffers;
+        final BlockingSet unfetchedSessionBuffers = this.unfetchedSessionBuffers;
+        final Set allSessionBuffers = this.allSessionBuffers;
         final Event event = new Event( type, nextFilter, data );
 
-        synchronized( readySessionBuffers )
+        synchronized( unfetchedSessionBuffers )
         {
             final SessionBuffer buf = getSessionBuffer( session );
             final Queue eventQueue = buf.eventQueue;
@@ -229,10 +229,10 @@
                 eventQueue.push( event );
             }
 
-            if( !busySessionBuffers.contains( buf ) )
+            if( !allSessionBuffers.contains( buf ) )
             {
-                busySessionBuffers.add( buf );
-                readySessionBuffers.add( buf );
+                allSessionBuffers.add( buf );
+                unfetchedSessionBuffers.add( buf );
             }
         }
     }
@@ -342,14 +342,14 @@
         private SessionBuffer fetchBuffer()
         {
             SessionBuffer buf;
-            BlockingSet readySessionBuffers = BaseThreadPool.this.readySessionBuffers;
-            synchronized( readySessionBuffers )
+            BlockingSet unfetchedSessionBuffers = BaseThreadPool.this.unfetchedSessionBuffers;
+            synchronized( unfetchedSessionBuffers )
             {
                 for( ;; )
                 {
                     try
                     {
-                        readySessionBuffers.waitForNewItem();
+                        unfetchedSessionBuffers.waitForNewItem();
                     }
                     catch( InterruptedException e )
                     {
@@ -363,15 +363,12 @@
                         }
                     }
 
-                    Iterator it = readySessionBuffers.iterator();
+                    Iterator it = unfetchedSessionBuffers.iterator();
                     while( it.hasNext() )
                     {
                         buf = ( SessionBuffer ) it.next();
                         it.remove();
-                        if( buf != null && !buf.eventQueue.isEmpty() )
-                        {
-                            return buf;
-                        }
+                        return buf;
                     }
                 }
             }
@@ -413,20 +410,20 @@
 
         private void releaseBuffer( SessionBuffer buf )
         {
-            final BlockingSet readySessionBuffers = BaseThreadPool.this.readySessionBuffers;
-            final Set busySessionBuffers = BaseThreadPool.this.busySessionBuffers;
+            final BlockingSet unfetchedSessionBuffers = BaseThreadPool.this.unfetchedSessionBuffers;
+            final Set allSessionBuffers = BaseThreadPool.this.allSessionBuffers;
             final Queue eventQueue = buf.eventQueue;
 
-            synchronized( readySessionBuffers )
+            synchronized( unfetchedSessionBuffers )
             {
                 if( eventQueue.isEmpty() )
                 {
-                    busySessionBuffers.remove( buf );
+                    allSessionBuffers.remove( buf );
                     removeSessionBuffer( buf );
                 }
                 else
                 {
-                    readySessionBuffers.add( buf );
+                    unfetchedSessionBuffers.add( buf );
                 }
             }
         }

Modified: directory/network/trunk/src/java/org/apache/mina/filter/ThreadPoolFilter.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/filter/ThreadPoolFilter.java?rev=325860&r1=325859&r2=325860&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/filter/ThreadPoolFilter.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/filter/ThreadPoolFilter.java Mon Oct
17 01:36:09 2005
@@ -93,8 +93,8 @@
     private final Map parents = new IdentityHashMap(); 
     private final Map buffers = new IdentityHashMap();
     private final Stack followers = new Stack();
-    private final BlockingSet readySessionBuffers = new BlockingSet();
-    private final Set busySessionBuffers = new HashSet();
+    private final BlockingSet unfetchedSessionBuffers = new BlockingSet();
+    private final Set allSessionBuffers = new HashSet();
 
     private Worker leader;
 
@@ -187,11 +187,11 @@
     protected void fireEvent( NextFilter nextFilter, IoSession session,
                               EventType type, Object data )
     {
-        final BlockingSet readySessionBuffers = this.readySessionBuffers;
-        final Set busySessionBuffers = this.busySessionBuffers;
+        final BlockingSet unfetchedSessionBuffers = this.unfetchedSessionBuffers;
+        final Set allSessionBuffers = this.allSessionBuffers;
         final Event event = new Event( type, nextFilter, data );
 
-        synchronized( readySessionBuffers )
+        synchronized( unfetchedSessionBuffers )
         {
             final SessionBuffer buf = getSessionBuffer( session );
             final Queue eventQueue = buf.eventQueue;
@@ -201,10 +201,10 @@
                 eventQueue.push( event );
             }
 
-            if( !busySessionBuffers.contains( buf ) )
+            if( !allSessionBuffers.contains( buf ) )
             {
-                busySessionBuffers.add( buf );
-                readySessionBuffers.add( buf );
+                allSessionBuffers.add( buf );
+                unfetchedSessionBuffers.add( buf );
             }
         }
     }
@@ -307,14 +307,14 @@
         private SessionBuffer fetchBuffer()
         {
             SessionBuffer buf;
-            BlockingSet readySessionBuffers = ThreadPoolFilter.this.readySessionBuffers;
-            synchronized( readySessionBuffers )
+            BlockingSet unfetchedSessionBuffers = ThreadPoolFilter.this.unfetchedSessionBuffers;
+            synchronized( unfetchedSessionBuffers )
             {
                 for( ;; )
                 {
                     try
                     {
-                        readySessionBuffers.waitForNewItem();
+                        unfetchedSessionBuffers.waitForNewItem();
                     }
                     catch( InterruptedException e )
                     {
@@ -328,15 +328,12 @@
                         }
                     }
 
-                    Iterator it = readySessionBuffers.iterator();
+                    Iterator it = unfetchedSessionBuffers.iterator();
                     while( it.hasNext() )
                     {
                         buf = ( SessionBuffer ) it.next();
                         it.remove();
-                        if( buf != null && !buf.eventQueue.isEmpty() )
-                        {
-                            return buf;
-                        }
+                        return buf;
                     }
                 }
             }
@@ -378,20 +375,20 @@
 
         private void releaseBuffer( SessionBuffer buf )
         {
-            final BlockingSet readySessionBuffers = ThreadPoolFilter.this.readySessionBuffers;
-            final Set busySessionBuffers = ThreadPoolFilter.this.busySessionBuffers;
+            final BlockingSet unfetchedSessionBuffers = ThreadPoolFilter.this.unfetchedSessionBuffers;
+            final Set allSessionBuffers = ThreadPoolFilter.this.allSessionBuffers;
             final Queue eventQueue = buf.eventQueue;
 
-            synchronized( readySessionBuffers )
+            synchronized( unfetchedSessionBuffers )
             {
                 if( eventQueue.isEmpty() )
                 {
-                    busySessionBuffers.remove( buf );
+                    allSessionBuffers.remove( buf );
                     removeSessionBuffer( buf );
                 }
                 else
                 {
-                    readySessionBuffers.add( buf );
+                    unfetchedSessionBuffers.add( buf );
                 }
             }
         }



Mime
View raw message