commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r1139168 - in /commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net: Poll.java Select.java
Date Fri, 24 Jun 2011 06:41:20 GMT
Author: mturk
Date: Fri Jun 24 06:41:20 2011
New Revision: 1139168

URL: http://svn.apache.org/viewvc?rev=1139168&view=rev
Log:
Add Select class and axe POLL prefix

Added:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/Select.java
  (with props)
Modified:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/Poll.java

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/Poll.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/Poll.java?rev=1139168&r1=1139167&r2=1139168&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/Poll.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/Poll.java Fri
Jun 24 06:41:20 2011
@@ -35,37 +35,37 @@ public final class Poll
     /**
      * There is data to read
      */
-    public static final short     POLLIN        = 0x0001;
+    public static final short     IN            = 0x0001;
     /**
      * Writing now will not block.
      */
-    public static final short     POLLOUT       = 0x0004;
+    public static final short     OUT           = 0x0004;
     /**
      * There is urgent data to read.
      * e.g., out-of-band data on TCP socket; pseudo-terminal master in  packet  mode
      * has seen state change in slave.
      */
-    public static final short     POLLPRI       = 0x0010;
+    public static final short     PRI           = 0x0010;
     /**
      * A Stream socket peer closed  connection, or shut down writing half of connection.
      */
-    public static final short     POLLRDHUP     = 0x0020;
+    public static final short     RDHUP         = 0x0020;
     /**
      * A stream-oriented connection was either diconnected or aborted.
      */
-    public static final short     POLLHUP       = 0x0040;
+    public static final short     HUP           = 0x0040;
     /**
      * An error has occurred.
      */
-    public static final short     POLLERR       = 0x0100;
+    public static final short     ERR           = 0x0100;
     /**
      * An invalid descriptor was used.
      */
-    public static final short     POLLNVAL      = 0x0200;
+    public static final short     NVAL          = 0x0200;
     /**
      * Time-To-Live event occurred.
      */
-    public static final short     POLLTTL       = 0x0400;
+    public static final short     TTL           = 0x0400;
 
 
     private static native int wait0(long[] fds, short[] events, short[] revents,

Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/Select.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/Select.java?rev=1139168&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/Select.java
(added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/Select.java
Fri Jun 24 06:41:20 2011
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package org.apache.commons.runtime.net;
+
+import org.apache.commons.runtime.Status;
+import org.apache.commons.runtime.InvalidArgumentException;
+import org.apache.commons.runtime.io.InvalidDescriptorException;
+
+/**
+ * Wait for some event on socket descriptor.
+ */
+public final class Select
+{
+    private Select()
+    {
+        // No instance
+    }
+
+    /**
+     * There is data to read
+     */
+    public static final short     IN            = 0x0001;
+    /**
+     * Writing now will not block.
+     */
+    public static final short     OUT           = 0x0004;
+    /**
+     * There is urgent data to read.
+     * e.g., out-of-band data on TCP socket; pseudo-terminal master in  packet  mode
+     * has seen state change in slave.
+     */
+    public static final short     PRI           = 0x0010;
+    /**
+     * A Stream socket peer closed  connection, or shut down writing half of connection.
+     */
+    public static final short     RDHUP         = 0x0020;
+    /**
+     * A stream-oriented connection was either diconnected or aborted.
+     */
+    public static final short     HUP           = 0x0040;
+    /**
+     * An error has occurred.
+     */
+    public static final short     ERR           = 0x0100;
+    /**
+     * An invalid descriptor was used.
+     */
+    public static final short     NVAL          = 0x0200;
+
+    private static native int wait0(long[] fds, short[] events, short[] revents,
+                                    int nelts, int timeout)
+        throws OutOfMemoryError,
+               InvalidArgumentException,
+               InvalidDescriptorException;
+    private static native short wait1(long fd, short events, int timeout);
+
+    private static short wait(long fd, short events, int timeout)
+        throws OutOfMemoryError,
+               InvalidArgumentException,
+               InvalidDescriptorException
+    {
+        if (fd == 0L)
+            throw new InvalidDescriptorException();
+        if ((events & 0x00ff) == 0)
+            throw new InvalidArgumentException();
+        short se = wait1(fd, events, timeout);
+        if (se == -1)
+            throw new OutOfMemoryError();
+        return se;
+    }
+
+    public static short wait(SocketEndpoint endpoint, short events, int timeout)
+        throws OutOfMemoryError,
+               InvalidArgumentException,
+               InvalidDescriptorException
+    {
+        return wait(endpoint.descriptor().fd(), events, timeout);
+    }
+
+    public static short wait(SocketEndpoint endpoint, short events)
+        throws OutOfMemoryError,
+               InvalidArgumentException,
+               InvalidDescriptorException
+    {
+        return wait(endpoint, events, -1);
+    }
+}

Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/Select.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message