Return-Path: X-Original-To: apmail-commons-commits-archive@minotaur.apache.org Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 102D86F73 for ; Fri, 24 Jun 2011 06:42:04 +0000 (UTC) Received: (qmail 51715 invoked by uid 500); 24 Jun 2011 06:42:03 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 50959 invoked by uid 500); 24 Jun 2011 06:41:46 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 50931 invoked by uid 99); 24 Jun 2011 06:41:42 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 24 Jun 2011 06:41:42 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 24 Jun 2011 06:41:40 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id A3FB223889B2 for ; Fri, 24 Jun 2011 06:41:20 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@commons.apache.org From: mturk@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110624064120.A3FB223889B2@eris.apache.org> 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