Class NioEndpoint.Poller

  • All Implemented Interfaces:
    Enclosing class:

    public class NioEndpoint.Poller
    extends java.lang.Object
    implements java.lang.Runnable
    Poller class.
    • Constructor Detail

      • Poller

        public Poller()
    • Method Detail

      • getKeyCount

        public int getKeyCount()
      • getSelector

        public java.nio.channels.Selector getSelector()
      • destroy

        protected void destroy()
        Destroy the poller.
      • add

        public void add​(NioEndpoint.NioSocketWrapper socketWrapper,
                        int interestOps)
        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).
        socketWrapper - to add to the poller
        interestOps - Operations for which to register this socket with the Poller
      • events

        public boolean events()
        Processes events in the event queue of the Poller.
        true if some events were processed, false if queue was empty
      • register

        public void register​(NioEndpoint.NioSocketWrapper socketWrapper)
        Registers a newly created socket with the poller.
        socketWrapper - The socket wrapper
      • run

        public void run()
        The background thread that adds sockets to the Poller, checks the poller for triggered events and hands the associated socket off to an appropriate processor as events occur.
        Specified by:
        run in interface java.lang.Runnable
      • timeout

        protected void timeout​(int keyCount,
                               boolean hasEvents)