Class TThreadedSelectorServer.SelectorThread

    • Constructor Detail

      • SelectorThread

        public SelectorThread()
                       throws java.io.IOException
        Set up the SelectorThread with an unbounded queue for incoming accepts.
        Throws:
        java.io.IOException - if a selector cannot be created
      • SelectorThread

        public SelectorThread​(int maxPendingAccepts)
                       throws java.io.IOException
        Set up the SelectorThread with an bounded queue for incoming accepts.
        Throws:
        java.io.IOException - if a selector cannot be created
      • SelectorThread

        public SelectorThread​(java.util.concurrent.BlockingQueue<TNonblockingTransport> acceptedQueue)
                       throws java.io.IOException
        Set up the SelectorThread with a specified queue for connections.
        Parameters:
        acceptedQueue - The BlockingQueue implementation for holding incoming accepted connections.
        Throws:
        java.io.IOException - if a selector cannot be created.
    • Method Detail

      • addAcceptedConnection

        public boolean addAcceptedConnection​(TNonblockingTransport accepted)
        Hands off an accepted connection to be handled by this thread. This method will block if the queue for new connections is at capacity.
        Parameters:
        accepted - The connection that has been accepted.
        Returns:
        true if the connection has been successfully added.
      • run

        public void run()
        The work loop. Handles selecting (read/write IO), dispatching, and managing the selection preferences of all existing connections.
        Specified by:
        run in interface java.lang.Runnable
        Overrides:
        run in class java.lang.Thread