directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pro...@apache.org
Subject svn commit: r471597 - /directory/branches/mina/1.2/core/src/main/java/org/apache/mina/transport/socket/nio/SocketAcceptor.java
Date Mon, 06 Nov 2006 01:08:10 GMT
Author: proyal
Date: Sun Nov  5 17:08:09 2006
New Revision: 471597

URL: http://svn.apache.org/viewvc?view=rev&rev=471597
Log:
use a CountDownLatch vs synchro

Modified:
    directory/branches/mina/1.2/core/src/main/java/org/apache/mina/transport/socket/nio/SocketAcceptor.java

Modified: directory/branches/mina/1.2/core/src/main/java/org/apache/mina/transport/socket/nio/SocketAcceptor.java
URL: http://svn.apache.org/viewvc/directory/branches/mina/1.2/core/src/main/java/org/apache/mina/transport/socket/nio/SocketAcceptor.java?view=diff&rev=471597&r1=471596&r2=471597
==============================================================================
--- directory/branches/mina/1.2/core/src/main/java/org/apache/mina/transport/socket/nio/SocketAcceptor.java
(original)
+++ directory/branches/mina/1.2/core/src/main/java/org/apache/mina/transport/socket/nio/SocketAcceptor.java
Sun Nov  5 17:08:09 2006
@@ -34,6 +34,7 @@
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.Executor;
 import java.util.concurrent.atomic.AtomicInteger;
 
@@ -134,19 +135,13 @@
 
         selector.wakeup();
 
-        synchronized( request )
+        try
         {
-            while( !request.done )
-            {
-                try
-                {
-                    request.wait();
-                }
-                catch( InterruptedException e )
-                {
-                    ExceptionMonitor.getInstance().exceptionCaught( e );
-                }
-            }
+            request.done.await();
+        }
+        catch( InterruptedException e )
+        {
+            ExceptionMonitor.getInstance().exceptionCaught( e );
         }
 
         if( request.exception != null )
@@ -155,7 +150,6 @@
         }
     }
 
-
     private synchronized void startupWorker() throws IOException
     {
         synchronized( lock )
@@ -196,19 +190,13 @@
 
         selector.wakeup();
 
-        synchronized( request )
+        try
         {
-            while( !request.done )
-            {
-                try
-                {
-                    request.wait();
-                }
-                catch( InterruptedException e )
-                {
-                    ExceptionMonitor.getInstance().exceptionCaught( e );
-                }
-            }
+            request.done.await();
+        }
+        catch( InterruptedException e )
+        {
+            ExceptionMonitor.getInstance().exceptionCaught( e );
         }
 
         if( request.exception != null )
@@ -424,12 +412,7 @@
             }
             finally
             {
-                synchronized( req )
-                {
-                    req.done = true;
-
-                    req.notifyAll();
-                }
+                req.done.countDown();
 
                 if( ssc != null && req.exception != null )
                 {
@@ -489,11 +472,7 @@
             }
             finally
             {
-                synchronized( request )
-                {
-                    request.done = true;
-                    request.notifyAll();
-                }
+                request.done.countDown();
 
                 if( request.exception == null )
                 {
@@ -511,8 +490,8 @@
         private InetSocketAddress address;
         private final IoHandler handler;
         private final IoServiceConfig config;
-        private IOException exception;
-        private boolean done;
+        private final CountDownLatch done = new CountDownLatch( 1 );
+        private volatile IOException exception;
 
         private RegistrationRequest( SocketAddress address, IoHandler handler, IoServiceConfig
config )
         {
@@ -522,13 +501,12 @@
         }
     }
 
-
     private static class CancellationRequest
     {
         private final SocketAddress address;
-        private boolean done;
+        private final CountDownLatch done = new CountDownLatch( 1 );
         private RegistrationRequest registrationRequest;
-        private RuntimeException exception;
+        private volatile RuntimeException exception;
 
         private CancellationRequest( SocketAddress address )
         {



Mime
View raw message