Package kilim.nio
Class NioSelectorScheduler
java.lang.Object
kilim.nio.NioSelectorScheduler
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) classclass(package private) classstatic interface -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic intSessionTask registers its endpoint with the selector by sending a SockEvent message on this mailbox.private final Task(package private) booleanprivate Selector(package private) AtomicBoolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintlisten(int port, Class<? extends SessionTask> sockTaskClass, Scheduler sockTaskScheduler) intlisten(int port, NioSelectorScheduler.SessionFactory factory, Scheduler sockTaskScheduler) private intlisten(NioSelectorScheduler.ListenTask t, Scheduler sockTaskScheduler) voidshutdown()
-
Field Details
-
LISTEN_BACKLOG
public static int LISTEN_BACKLOG -
sel
-
selectorThread
-
regbox
SessionTask registers its endpoint with the selector by sending a SockEvent message on this mailbox. -
update
AtomicBoolean update -
regtask
-
running
volatile boolean running
-
-
Constructor Details
-
NioSelectorScheduler
- Throws:
IOException
-
-
Method Details
-
listen
public int listen(int port, NioSelectorScheduler.SessionFactory factory, Scheduler sockTaskScheduler) throws IOException - Throws:
IOException
-
listen
public int listen(int port, Class<? extends SessionTask> sockTaskClass, Scheduler sockTaskScheduler) throws IOException - Throws:
IOException
-
listen
-
shutdown
public void shutdown()
-