commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r1129033 - in /commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime: net/Selector.java platform/unix/SocketSelectorImpl.java
Date Mon, 30 May 2011 07:58:26 GMT
Author: mturk
Date: Mon May 30 07:58:25 2011
New Revision: 1129033

URL: http://svn.apache.org/viewvc?rev=1129033&view=rev
Log:
Implement cancel method

Modified:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/Selector.java
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/SocketSelectorImpl.java

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/Selector.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/Selector.java?rev=1129033&r1=1129032&r2=1129033&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/Selector.java
(original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/Selector.java
Mon May 30 07:58:25 2011
@@ -85,7 +85,14 @@ public abstract class Selector implement
                IllegalSelectorException,
                OverflowException,
                IOException;
-        
+    /**
+     * Unregister the selection key from this selector.
+     *
+     * @throws IllegalSelectorException if this selector is closed.
+     */
+    protected abstract void cancel(SelectionKey key)
+        throws IllegalSelectorException;
+    
     /**
      * Free the allocated resource by the Operating system.
      * <p>

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/SocketSelectorImpl.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/SocketSelectorImpl.java?rev=1129033&r1=1129032&r2=1129033&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/SocketSelectorImpl.java
(original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/SocketSelectorImpl.java
Mon May 30 07:58:25 2011
@@ -94,7 +94,7 @@ final class SocketSelectorImpl extends S
         throws IllegalSelectorException, ClosedDescriptorException, OverflowException, IOException
     {
         SelectionKeyImpl skey = (SelectionKeyImpl)key;
-        int fd   = skey.endpoint().descriptor().fd();
+        int fd  = skey.endpoint().descriptor().fd();
         if (fd == -1)
             throw new ClosedDescriptorException();
         if (pollset == 0L)
@@ -112,6 +112,19 @@ final class SocketSelectorImpl extends S
     }
 
     @Override
+    protected void cancel(SelectionKey key)
+        throws IllegalSelectorException
+    {
+        SelectionKeyImpl skey = (SelectionKeyImpl)key;
+        int fd  = skey.endpoint().descriptor().fd();
+        if (fd == -1)
+            return;
+        if (pollset == 0L)
+            throw new IllegalSelectorException();
+        del0(pollset, skey, fd);
+    }
+
+    @Override
     public void close()
         throws IOException
     {



Mime
View raw message