Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   *  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.tomcat.jni;

Poll

Author(s):
Mladen Turk
Version:
$Revision: 515 $, $Date: 2008-03-17 22:02:23 +0100 (Mon, 17 Mar 2008) $
 
 
 public class Poll {

    
Poll options
 
     public static final int APR_POLLIN   = 0x001; 
Can read without blocking
 
     public static final int APR_POLLPRI  = 0x002; 
Priority data available
 
     public static final int APR_POLLOUT  = 0x004; 
Can write without blocking
 
     public static final int APR_POLLERR  = 0x010; 
Pending error
 
     public static final int APR_POLLHUP  = 0x020; 
Hangup occurred
 
     public static final int APR_POLLNVAL = 0x040; 
Descriptior invalid
 

    
Pollset Flags
 
    
Adding or Removing a Descriptor is thread safe
 
     public static final int APR_POLLSET_THREADSAFE = 0x001;


    
Used in apr_pollfd_t to determine what the apr_descriptor is apr_datatype_e enum
 
     public static final int APR_NO_DESC       = 0; 
nothing here
 
     public static final int APR_POLL_SOCKET   = 1; 
descriptor refers to a socket
 
     public static final int APR_POLL_FILE     = 2; 
descriptor refers to a file
 
     public static final int APR_POLL_LASTDESC = 3; 
descriptor is the last one in the list
 

    
Setup a pollset object. If flags equals APR_POLLSET_THREADSAFE, then a pollset is created on which it is safe to make concurrent calls to apr_pollset_add(), apr_pollset_remove() and apr_pollset_poll() from separate threads. This feature is only supported on some platforms; the apr_pollset_create() call will fail with APR_ENOTIMPL on platforms where it is not supported.

Parameters:
size The maximum number of descriptors that this pollset can hold
p The pool from which to allocate the pollset
flags Optional flags to modify the operation of the pollset.
ttl Maximum time to live for a particular socket.
Returns:
The pointer in which to return the newly created object
 
     public static native long create(int sizelong pint flagslong ttl)
         throws Error;
    
Destroy a pollset object

Parameters:
pollset The pollset to destroy
 
     public static native int destroy(long pollset);

    
Add a socket or to a pollset If you set client_data in the descriptor, that value will be returned in the client_data field whenever this descriptor is signalled in apr_pollset_poll().

Parameters:
pollset The pollset to which to add the descriptor
sock The sockets to add
data Client data to add
reqevents requested events
 
     public static native int add(long pollsetlong sock,
                                  int reqevents);

    
Remove a descriptor from a pollset

Parameters:
pollset The pollset from which to remove the descriptor
sock The socket to remove
 
     public static native int remove(long pollsetlong sock);

    
Block for activity on the descriptor(s) in a pollset

Parameters:
pollset The pollset to use
timeout Timeout in microseconds
descriptors Array of signalled descriptors (output parameter) The desctiptor array must be two times the size of pollset. and are populated as follows:
 descriptors[n + 0] -> returned events
 descriptors[n + 1] -> socket
 
remove Remove signaled descriptors from pollset
Returns:
Number of signalled descriptors (output parameter) or negative APR error code.
    public static native int poll(long pollsetlong timeout,
                                  long [] descriptorsboolean remove);

    
Maintain on the descriptor(s) in a pollset

Parameters:
pollset The pollset to use
descriptors Array of signalled descriptors (output parameter) The desctiptor array must be the size of pollset. and are populated as follows:
 descriptors[n] -> socket
 
remove Remove signaled descriptors from pollset
Returns:
Number of signalled descriptors (output parameter) or negative APR error code.
    public static native int maintain(long pollsetlong [] descriptors,
                                      boolean remove);

    
Set the socket time to live.

Parameters:
pollset The pollset to use
ttl Timeout in microseconds
    public static native void setTtl(long pollsetlong ttl);

    
Get the socket time to live.

Parameters:
pollset The pollset to use
Returns:
Timeout in microseconds
    public static native long getTtl(long pollset);

    
Return all descriptor(s) in a pollset

Parameters:
pollset The pollset to use
descriptors Array of descriptors (output parameter) The desctiptor array must be two times the size of pollset. and are populated as follows:
 descriptors[n + 0] -> returned events
 descriptors[n + 1] -> socket
 
Returns:
Number of descriptors (output parameter) in the Poll or negative APR error code.
    public static native int pollset(long pollsetlong [] descriptors);
New to GrepCode? Check out our FAQ X