harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ton...@apache.org
Subject svn commit: r734911 - in /harmony/enhanced/classlib/trunk/modules/nio: META-INF/MANIFEST.MF src/main/java/common/java/nio/channels/spi/AbstractSelector.java src/main/java/common/org/apache/harmony/nio/internal/SelectorImpl.java
Date Fri, 16 Jan 2009 05:32:41 GMT
Author: tonywu
Date: Thu Jan 15 21:32:40 2009
New Revision: 734911

URL: http://svn.apache.org/viewvc?rev=734911&view=rev
Log:
Apply patch for HARMONY-6073 [classlib][nio]Is selector.close() should be non-blocking

Modified:
    harmony/enhanced/classlib/trunk/modules/nio/META-INF/MANIFEST.MF
    harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/spi/AbstractSelector.java
    harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SelectorImpl.java

Modified: harmony/enhanced/classlib/trunk/modules/nio/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/META-INF/MANIFEST.MF?rev=734911&r1=734910&r2=734911&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio/META-INF/MANIFEST.MF (original)
+++ harmony/enhanced/classlib/trunk/modules/nio/META-INF/MANIFEST.MF Thu Jan 15 21:32:40 2009
@@ -19,6 +19,7 @@
  java.nio.charset,
  java.security,
  java.util,
+ java.util.concurrent.atomic,
  org.apache.harmony.kernel.vm,
  org.apache.harmony.luni.net,
  org.apache.harmony.luni.platform,

Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/spi/AbstractSelector.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/spi/AbstractSelector.java?rev=734911&r1=734910&r2=734911&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/spi/AbstractSelector.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/spi/AbstractSelector.java
Thu Jan 15 21:32:40 2009
@@ -22,6 +22,7 @@
 import java.nio.channels.Selector;
 import java.util.HashSet;
 import java.util.Set;
+import java.util.concurrent.atomic.AtomicBoolean;
 
 /**
  * Abstract class for selectors.
@@ -33,7 +34,7 @@
  * 
  */
 public abstract class AbstractSelector extends Selector {
-    private volatile boolean isOpen = true;
+    private final AtomicBoolean isOpen = new AtomicBoolean(true);
 
     private SelectorProvider provider = null;
 
@@ -58,9 +59,8 @@
      * @see java.nio.channels.Selector#close()
      */
     @Override
-    public synchronized final void close() throws IOException {
-        if (isOpen) {
-            isOpen = false;
+    public final void close() throws IOException {
+        if (isOpen.getAndSet(false)) {
             implCloseSelector();
         }
     }
@@ -78,7 +78,7 @@
      */
     @Override
     public final boolean isOpen() {
-        return isOpen;
+        return isOpen.get();
     }
 
     /**

Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SelectorImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SelectorImpl.java?rev=734911&r1=734910&r2=734911&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SelectorImpl.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SelectorImpl.java
Thu Jan 15 21:32:40 2009
@@ -138,6 +138,7 @@
      */
     @Override
     protected void implCloseSelector() throws IOException {
+        wakeup();
         synchronized (this) {
             synchronized (keysSet) {
                 synchronized (selectedKeys) {
@@ -147,7 +148,6 @@
                             deregister((AbstractSelectionKey) sk);
                         }
                     }
-                    wakeup();
                 }
             }
         }



Mime
View raw message