org.apache.tomcat.util.net

## Class AprEndpoint.Poller

- java.lang.Object
- - org.apache.tomcat.util.net.AprEndpoint.Poller

- All Implemented Interfaces:
    Runnable
  Enclosing class:
    AprEndpoint

      public class AprEndpoint.Poller
      extends Object
      implements Runnable

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected int` | `actualPollerSize` Actual poller size.
    `protected AprEndpoint.SocketList` | `addList` List of sockets to be added to the poller.
    `protected long[]` | `desc` Socket descriptors.
    `protected long` | `lastMaintain` Last run of maintain.
    `protected int` | `pollerCount` Amount of low level pollers in use by this poller.
    `protected long[]` | `pollers` Pointers to the pollers.
    `protected int[]` | `pollerSpace` Amount of spots left in the poller.
    `protected int` | `pollerTime` Timeout value for the poll call.
    `protected long` | `pool` Root pool.
    `protected AprEndpoint.SocketTimeouts` | `timeouts` Structure used for storing timeouts.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AprEndpoint.Poller()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `add(long socket, int timeout, boolean read, boolean write)` Add specified socket and associated pool to the poller.
    `protected boolean` | `addToPoller(long socket, int events)` Add specified socket to one of the pollers.
    `protected boolean` | `close(long socket)`
    `protected void` | `destroy()` Destroy the poller.
    `int` | `getConnectionCount()`
    `protected void` | `init()` Create the poller.
    `protected void` | `maintain()` Timeout checks.
    `void` | `run()` The background thread that listens for incoming TCP/IP connections and hands them off to an appropriate processor.
    `protected void` | `stop()`
    `String` | `toString()` Displays the list of sockets in the pollers.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### pollers

          protected long[] pollers

      Pointers to the pollers.

    - #### actualPollerSize

          protected int actualPollerSize

      Actual poller size.

    - #### pollerSpace

          protected int[] pollerSpace

      Amount of spots left in the poller.

    - #### pollerCount

          protected int pollerCount

      Amount of low level pollers in use by this poller.

    - #### pollerTime

          protected int pollerTime

      Timeout value for the poll call.

    - #### pool

          protected long pool

      Root pool.

    - #### desc

          protected long[] desc

      Socket descriptors.

    - #### addList

          protected AprEndpoint.SocketList addList

      List of sockets to be added to the poller.

    - #### timeouts

          protected AprEndpoint.SocketTimeouts timeouts

      Structure used for storing timeouts.

    - #### lastMaintain

          protected long lastMaintain

      Last run of maintain. Maintain will run approximately once every one second (may be slightly longer between runs).

  - ### Constructor Detail

    - #### AprEndpoint.Poller

          public AprEndpoint.Poller()

  - ### Method Detail

    - #### getConnectionCount

          public int getConnectionCount()

    - #### init

          protected void init()

      Create the poller. With some versions of APR, the maximum poller size will be 62 (recompiling APR is necessary to remove this limitation).

    - #### stop

          protected void stop()

    - #### destroy

          protected void destroy()

      Destroy the poller.

    - #### add

          public void add(long socket,
                 int timeout,
                 boolean read,
                 boolean write)

      Add specified socket and associated pool to the poller. The socket will be added to a temporary array, and polled first after a maximum amount of time equal to pollTime (in most cases, latency will be much lower, however). Note: If both read and write are false, the socket will only be checked for timeout; if the socket was already present in the poller, a callback event will be generated and the socket will be removed from the poller.
      Parameters:
        `socket` - to add to the poller
        `timeout` - to use for this connection
        `read` - to do read polling
        `write` - to do write polling

    - #### addToPoller

          protected boolean addToPoller(long socket,
                            int events)

      Add specified socket to one of the pollers. Must only be called from `run()`.

    - #### close

          protected boolean close(long socket)

    - #### maintain

          protected void maintain()

      Timeout checks.

    - #### toString

          public String toString()

      Displays the list of sockets in the pollers.
      Overrides:
        `toString` in class `Object`

    - #### run

          public void run()

      The background thread that listens for incoming TCP/IP connections and hands them off to an appropriate processor.
      Specified by:
        `run` in interface `Runnable`

Copyright © 2000-2017 Apache Software Foundation. All Rights Reserved.