org.apache.tomcat.util.net

## Class NioEndpoint.Poller

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

- All Implemented Interfaces:
    Runnable
  Enclosing class:
    NioEndpoint

      public class NioEndpoint.Poller
      extends Object
      implements Runnable

  Poller class.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected boolean` | `close`
    `protected ConcurrentLinkedQueue<Runnable>` | `events`
    `protected int` | `keyCount`
    `protected long` | `nextExpiration`
    `protected Selector` | `selector`
    `protected AtomicLong` | `wakeupCounter`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `NioEndpoint.Poller()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `add(NioChannel socket)` Add specified socket and associated pool to the poller.
    `void` | `add(NioChannel socket, int interestOps)`
    `void` | `addEvent(Runnable event)` Deprecated.
    `NioEndpoint.KeyAttachment` | `cancelledKey(SelectionKey key, SocketStatus status, boolean dispatch)`
    `void` | `cometInterest(NioChannel socket)` Deprecated.
    `protected void` | `destroy()` Destroy the poller.
    `boolean` | `events()` Processes events in the event queue of the Poller.
    `int` | `getKeyCount()`
    `Selector` | `getSelector()`
    `protected boolean` | `processKey(SelectionKey sk, NioEndpoint.KeyAttachment attachment)`
    `SendfileState` | `processSendfile(SelectionKey sk, NioEndpoint.KeyAttachment attachment, boolean calledByProcessor)`
    `protected void` | `reg(SelectionKey sk, NioEndpoint.KeyAttachment attachment, int intops)`
    `void` | `register(NioChannel socket)`
    `void` | `run()` The background thread that listens for incoming TCP/IP connections and hands them off to an appropriate processor.
    `protected void` | `timeout(int keyCount, boolean hasEvents)`
    `protected void` | `unreg(SelectionKey sk, NioEndpoint.KeyAttachment attachment, int readyOps)`

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

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

- - ### Field Detail

    - #### selector

          protected Selector selector

    - #### events

          protected ConcurrentLinkedQueue<Runnable> events

    - #### close

          protected volatile boolean close

    - #### nextExpiration

          protected long nextExpiration

    - #### wakeupCounter

          protected AtomicLong wakeupCounter

    - #### keyCount

          protected volatile int keyCount

  - ### Constructor Detail

    - #### NioEndpoint.Poller

          public NioEndpoint.Poller()
                             throws IOException

      Throws:
        `IOException`

  - ### Method Detail

    - #### getKeyCount

          public int getKeyCount()

    - #### getSelector

          public Selector getSelector()

    - #### destroy

          protected void destroy()

      Destroy the poller.

    - #### addEvent

          @Deprecated
          public void addEvent(Runnable event)

      Deprecated.
      Only used in this class. Will be made private in Tomcat 8.0.x

    - #### cometInterest

          @Deprecated
          public void cometInterest(NioChannel socket)

      Deprecated.
      Unused. Will be removed in Tomcat 8.0.x

    - #### add

          public void add(NioChannel socket)

      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).
      Parameters:
        `socket` - to add to the poller

    - #### add

          public void add(NioChannel socket,
                 int interestOps)

    - #### events

          public boolean events()

      Processes events in the event queue of the Poller.
      Returns:
        `true` if some events were processed, `false` if queue was empty

    - #### register

          public void register(NioChannel socket)

    - #### cancelledKey

          public NioEndpoint.KeyAttachment cancelledKey(SelectionKey key,
                                               SocketStatus status,
                                               boolean dispatch)

    - #### 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`

    - #### processKey

          protected boolean processKey(SelectionKey sk,
                           NioEndpoint.KeyAttachment attachment)

    - #### processSendfile

          public SendfileState processSendfile(SelectionKey sk,
                                      NioEndpoint.KeyAttachment attachment,
                                      boolean calledByProcessor)

    - #### unreg

          protected void unreg(SelectionKey sk,
                   NioEndpoint.KeyAttachment attachment,
                   int readyOps)

    - #### reg

          protected void reg(SelectionKey sk,
                 NioEndpoint.KeyAttachment attachment,
                 int intops)

    - #### timeout

          protected void timeout(int keyCount,
                     boolean hasEvents)

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