Package org.apache.tomcat.jni
Class Poll
java.lang.Object
org.apache.tomcat.jni.Poll
Poll
- Author:
- Mladen Turk
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intUsed in apr_pollfd_t to determine what the apr_descriptor is apr_datatype_e enumstatic final intdescriptor refers to a socketstatic final intdescriptor refers to a filestatic final intnothing herestatic final intPending errorstatic final intHangup occurredstatic final intCan read without blockingstatic final intDescriptor invalidstatic final intCan write without blockingstatic final intPriority data availablestatic final intAdding or Removing a Descriptor is thread safe -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intadd(long pollset, long sock, int reqevents) Add a socket to a pollset with the default timeout.static intaddWithTimeout(long pollset, long sock, int reqevents, long timeout) Add a socket to a pollset with a specific timeout.static longcreate(int size, long p, int flags, long ttl) Setup a pollset object.static intdestroy(long pollset) Destroy a pollset objectstatic longgetTtl(long pollset) Get the socket time to live.static intinterrupt(long pollset) Make poll() return.static intmaintain(long pollset, long[] descriptors, boolean remove) Maintain on the descriptor(s) in a pollsetstatic intpoll(long pollset, long timeout, long[] descriptors, boolean remove) Block for activity on the descriptor(s) in a pollsetstatic intpollset(long pollset, long[] descriptors) Return all descriptor(s) in a pollsetstatic intremove(long pollset, long sock) Remove a descriptor from a pollsetstatic voidsetTtl(long pollset, long ttl) Set the socket time to live.static booleanwakeable(long pollset) Check if interrupt() is allowed.
-
Field Details
-
APR_POLLIN
public static final int APR_POLLINCan read without blocking- See Also:
-
APR_POLLPRI
public static final int APR_POLLPRIPriority data available- See Also:
-
APR_POLLOUT
public static final int APR_POLLOUTCan write without blocking- See Also:
-
APR_POLLERR
public static final int APR_POLLERRPending error- See Also:
-
APR_POLLHUP
public static final int APR_POLLHUPHangup occurred- See Also:
-
APR_POLLNVAL
public static final int APR_POLLNVALDescriptor invalid- See Also:
-
APR_POLLSET_THREADSAFE
public static final int APR_POLLSET_THREADSAFEAdding or Removing a Descriptor is thread safe- See Also:
-
APR_NO_DESC
public static final int APR_NO_DESCUsed in apr_pollfd_t to determine what the apr_descriptor is apr_datatype_e enum- See Also:
-
APR_POLL_SOCKET
public static final int APR_POLL_SOCKETnothing here- See Also:
-
APR_POLL_FILE
public static final int APR_POLL_FILEdescriptor refers to a socket- See Also:
-
APR_POLL_LASTDESC
public static final int APR_POLL_LASTDESCdescriptor refers to a file- See Also:
-
-
Constructor Details
-
Poll
public Poll()
-
-
Method Details
-
create
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 holdp- The pool from which to allocate the pollsetflags- 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
- Throws:
Error- Pollset creation failed
-
destroy
public static int destroy(long pollset) Destroy a pollset object- Parameters:
pollset- The pollset to destroy- Returns:
- the operation status
-
add
public static int add(long pollset, long sock, int reqevents) Add a socket to a pollset with the default timeout.- Parameters:
pollset- The pollset to which to add the socketsock- The sockets to addreqevents- requested events- Returns:
- the operation status
-
addWithTimeout
public static int addWithTimeout(long pollset, long sock, int reqevents, long timeout) Add a socket to a pollset with a specific timeout.- Parameters:
pollset- The pollset to which to add the socketsock- The sockets to addreqevents- requested eventstimeout- requested timeout in microseconds (-1 for infinite)- Returns:
- the operation status
-
remove
public static int remove(long pollset, long sock) Remove a descriptor from a pollset- Parameters:
pollset- The pollset from which to remove the descriptorsock- The socket to remove- Returns:
- the operation status
-
poll
public static int poll(long pollset, long timeout, long[] descriptors, boolean remove) Block for activity on the descriptor(s) in a pollset- Parameters:
pollset- The pollset to usetimeout- Timeout in microsecondsdescriptors- Array of signaled descriptors (output parameter) The descriptor array must be two times the size of pollset. and are populated as follows:descriptors[2n + 0] -> returned events descriptors[2n + 1] -> socket
remove- Remove signaled descriptors from pollset- Returns:
- Number of signaled descriptors (output parameter) or negative APR error code.
-
maintain
public static int maintain(long pollset, long[] descriptors, boolean remove) Maintain on the descriptor(s) in a pollset- Parameters:
pollset- The pollset to usedescriptors- Array of signaled descriptors (output parameter) The descriptor array must be the size of pollset. and are populated as follows:descriptors[n] -> socket
remove- Remove signaled descriptors from pollset- Returns:
- Number of signaled descriptors (output parameter) or negative APR error code.
-
setTtl
public static void setTtl(long pollset, long ttl) Set the socket time to live.- Parameters:
pollset- The pollset to usettl- Timeout in microseconds
-
getTtl
public static long getTtl(long pollset) Get the socket time to live.- Parameters:
pollset- The pollset to use- Returns:
- Timeout in microseconds
-
pollset
public static int pollset(long pollset, long[] descriptors) Return all descriptor(s) in a pollset- Parameters:
pollset- The pollset to usedescriptors- Array of descriptors (output parameter) The descriptor array must be two times the size of pollset. and are populated as follows:descriptors[2n + 0] -> returned events descriptors[2n + 1] -> socket
- Returns:
- Number of descriptors (output parameter) in the Poll or negative APR error code.
-
interrupt
public static int interrupt(long pollset) Make poll() return.- Parameters:
pollset- The pollset to use- Returns:
- Negative APR error code
-
wakeable
public static boolean wakeable(long pollset) Check if interrupt() is allowed.- Parameters:
pollset- The pollset to use- Returns:
trueifinterrupt(long)is allowed, elsefalse
-