Package kilim.nio

Class NioSelectorScheduler


  • public class NioSelectorScheduler
    extends java.lang.Object
    This class wraps a selector and runs it in a separate thread. It runs one or more ListenTasks (bound to their respective ports), which in turn spawn as many session tasks (see listen(int, Class, Scheduler)) as the number of new http connections. The supplied scheduler is used to execute the tasks. It is possible, although not typical, to run tasks in the NioSelectorScheduler itself, as it too is a scheduler. Usage is as follows:
      NioSelectorScheduler nss = new NioSelectorScheduler();
      nss.listen(8080, MySessionTask.class, Scheduler.getDefaultScheduler();
      
      class MySessionTask extends SessionTask {
      ...
      }
     
    See Also:
    SessionTask
    • Field Detail

      • LISTEN_BACKLOG

        public static int LISTEN_BACKLOG
      • sel

        private java.nio.channels.Selector sel
      • regbox

        final Mailbox<SockEvent> regbox
        SessionTask registers its endpoint with the selector by sending a SockEvent message on this mailbox.
      • update

        java.util.concurrent.atomic.AtomicBoolean update
      • regtask

        private final Task regtask
      • running

        volatile boolean running
    • Constructor Detail

      • NioSelectorScheduler

        public NioSelectorScheduler()
                             throws java.io.IOException
        Throws:
        java.io.IOException