|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.indi.reactor.Reactor
public class Reactor
A simple implementation of the reactor pattern (similar to eventloop /event
driven system / event demultiplexer) around the java newIO system. Just
register event handlers with the reactor and call handle events frequntly.
The callbackmethods of the event handlers will be called as soon as the
corresponding events have been detected. See
http://www.cs.wustl.edu/~schmidt/PDF/reactor-siemens.pdf
for a basic
introduction to the concept.
Field Summary | |
---|---|
protected java.nio.channels.Selector |
selector
The Selector used by the Reactor to listen for IO events |
Constructor Summary | |
---|---|
Reactor()
Class constructor |
Method Summary | |
---|---|
int |
handleEvents(long timeout)
Call the methods frequently. |
void |
register(EventHandler h,
int ops)
Registers a new IO-EventHandler with the reactor |
void |
register(QueueHandler h)
Register a new Queue-EventHandler with the reactor |
void |
register(TimerHandler h)
Register a new Timer-EventHanlder with the reactor |
void |
unregister(EventHandler h)
Unregister a IO-EventHandler |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.nio.channels.Selector selector
Constructor Detail |
---|
public Reactor() throws java.io.IOException
java.io.IOException
Method Detail |
---|
public void register(EventHandler h, int ops)
h
- EventHandler to be installedops
- Bitmask describing the IO Events to listen to.public void register(QueueHandler h)
h
- QueueHandler to be regsiteredpublic void register(TimerHandler h)
h
- the TimeHandler to be registeredpublic void unregister(EventHandler h)
h
- public int handleEvents(long timeout) throws java.io.IOException
timeout
- the maximum time to wait for events in miliseconds
java.io.IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |