|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.mindbright.nio.Switchboard
public class Switchboard
A central switchboard class which handles all the waiting on different events. This subclass handles the java.nio case.
Method Summary | |
---|---|
void |
checkForDeadlock()
Check if the current thread is a thread which is allowed to wait. |
NetworkConnection |
connect(java.net.InetAddress addr,
int port,
boolean block)
Establish a new network connection. |
void |
debug2(java.lang.String cls,
java.lang.String meth,
java.lang.String msg)
|
static Switchboard |
getSwitchboard()
Get the global switchboard instance. |
void |
notifyWhenConnected(NetworkConnection conn,
long timeout,
NIOCallback callback)
Wait for a network connection to become connected. |
protected void |
read(java.nio.channels.spi.AbstractSelectableChannel channel,
java.nio.ByteBuffer buf,
NIOCallback callback,
NonBlockingInput lock,
boolean shortDataOk)
|
java.lang.Object |
registerTimer(long interval,
TimerCallback callback)
Register a callback which is called regularly |
void |
run()
This is the main loop which never exits. |
void |
setLog(Log log)
Set the log to use |
void |
unregisterTimer(java.lang.Object key)
Unregister a previously registered timer callback |
protected void |
write(java.nio.channels.spi.AbstractSelectableChannel channel,
java.nio.ByteBuffer buf,
NonBlockingOutput lock)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static Switchboard getSwitchboard()
public void setLog(Log log)
log
- log to usepublic java.lang.Object registerTimer(long interval, TimerCallback callback)
interval
- minimum number of milliseconds between callscallback
- class to call back
public void unregisterTimer(java.lang.Object key)
key
- the handler returned from registerTimerpublic NetworkConnection connect(java.net.InetAddress addr, int port, boolean block) throws java.io.IOException
addr
- address of server to connect toport
- port to connect toblock
- true if the call should block until the connection
is established
java.io.IOException
public void notifyWhenConnected(NetworkConnection conn, long timeout, NIOCallback callback)
conn
- the network connection to wait ontimeout
- max time, in milliseconds, the connect may takecallback
- function to call back once connection is done
or has timed out.public final void debug2(java.lang.String cls, java.lang.String meth, java.lang.String msg)
protected void read(java.nio.channels.spi.AbstractSelectableChannel channel, java.nio.ByteBuffer buf, NIOCallback callback, NonBlockingInput lock, boolean shortDataOk) throws java.io.IOException
java.io.IOException
public void checkForDeadlock() throws java.lang.Exception
java.lang.Exception
- if the current thread is the event handling threadprotected void write(java.nio.channels.spi.AbstractSelectableChannel channel, java.nio.ByteBuffer buf, NonBlockingOutput lock) throws java.io.IOException
java.io.IOException
public void run()
run
in interface java.lang.Runnable
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |