|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectde.unkrig.commons.io.Multiplexer
public class Multiplexer
A thin wrapper for the JDK Selector that also manages timers and multiple threads.
| Nested Class Summary | |
|---|---|
static interface |
Multiplexer.TimerKey
An identifier for a created timer. |
| Constructor Summary | |
|---|---|
Multiplexer()
|
|
| Method Summary | |
|---|---|
java.nio.channels.SelectionKey |
register(java.nio.channels.SelectableChannel sc,
int ops,
RunnableWhichThrows<java.io.IOException> runnable)
Executes the given runnable exactly once iff the channel becomes acceptable,
connected, readable and/or writable. |
void |
run()
Handles channels and timers; returns never. |
void |
stop()
Causes run() to complete normally soon; if run() is not currently being executed, then
calling stop() has no effect. |
Multiplexer.TimerKey |
timer(long expiry,
java.lang.Runnable runnable)
Registers the given runnable for exactly one execution by this Multiplexer's run() method
when the current time is equal to (or slightly greater than) expiry. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Multiplexer()
throws java.io.IOException
java.io.IOException| Method Detail |
|---|
public void run()
throws java.io.IOException
stop() was called.
run in interface RunnableWhichThrows<java.io.IOException>java.io.IOException
public java.nio.channels.SelectionKey register(java.nio.channels.SelectableChannel sc,
int ops,
RunnableWhichThrows<java.io.IOException> runnable)
throws java.nio.channels.ClosedChannelException
acceptable,
connected, readable and/or writable.
To cancel the reigstration, invoke SelectionKey.cancel() on the returned object.
java.nio.channels.ClosedChannelException
public Multiplexer.TimerKey timer(long expiry,
java.lang.Runnable runnable)
Multiplexer's run() method
when the current time is equal to (or slightly greater than) expiry.
Registering the same runnable more than once (and even with equal expiry) will lead to the runnable
being run that many times.
Registering a runnable for an expiry that lies in the past will lead to the runnable being executed by
this Multiplexer's run() method very soon.
Invoking the Multiplexer.TimerKey.cancel() method on the returned object prevents the runnable from being
executed (iff its execution has not yet begun).
public void stop()
run() to complete normally soon; if run() is not currently being executed, then
calling stop() has no effect.
stop in interface Stoppable
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||