|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object au.com.terabit.jproactor.AsynchChannel
public abstract class AsynchChannel
The AsynchChannel
is an intermidiate interface that serves as
mediator between Demultiplexor
and AsynchHandler
All implemented protocols should be based on this interface.
$Revision$ $Date$
IOOperation
Nested Class Summary | |
---|---|
static class |
AsynchChannel.State
Channel states |
Field Summary | |
---|---|
protected AsynchChannel.State |
m_channelState
channelState : OPENED, CONNECTED, CLOSING, CLOSED |
protected java.util.concurrent.locks.ReentrantLock |
m_lock
Internal lock for synchronization |
IOStatistic |
m_readInfo
queue for the completed write operations |
protected java.util.concurrent.ConcurrentLinkedQueue<IOOperation> |
m_readQue
queue for the requested read operations |
IOStatistic |
m_writeInfo
|
protected java.util.concurrent.ConcurrentLinkedQueue<IOOperation> |
m_writeQue
queue for the requested write operations |
Constructor Summary | |
---|---|
AsynchChannel()
Creates AsynchChannel instance given specified
Demultiplexor , AsynchHandler and
SelectableChannel instances. |
Method Summary | |
---|---|
OpAccept |
accept(AsynchAcceptHandler handler)
Request to execute accept operation. |
protected boolean |
checkForClose()
this method is should be called by derived implemnations with locked m_lock |
void |
close()
|
OpConnect |
connect(java.net.SocketAddress addr,
AsynchConnectHandler handler)
Request to execute connect operation. |
protected boolean |
dispatchCompletions(java.util.concurrent.ConcurrentLinkedQueue<IOOperation> completedQue)
|
protected void |
enqueueOperation(IOOperation op,
java.util.concurrent.ConcurrentLinkedQueue<IOOperation> que,
IOStatistic info)
|
protected IOOperation |
executeListAndAdd(java.util.concurrent.ConcurrentLinkedQueue<IOOperation> reqQue,
boolean flgCancel,
java.util.concurrent.ConcurrentLinkedQueue<IOOperation> completedQue)
|
protected IOOperation |
executeListAndDispatch(java.util.concurrent.ConcurrentLinkedQueue<IOOperation> reqQue)
|
protected boolean |
executeOp(IOOperation op,
boolean flgCancel)
|
protected boolean |
executeOpAndAdd(IOOperation op,
boolean flgCancel,
java.util.concurrent.ConcurrentLinkedQueue<IOOperation> completedQue)
|
protected abstract AsynchChannel |
finishAccept(OpAccept op)
|
protected abstract boolean |
finishConnect(OpConnect op)
|
protected abstract int |
finishRead(OpRead op)
|
protected abstract int |
finishWrite(OpWrite op)
|
AsynchChannelHandler |
getChannelHandler()
Returns AsynchCloseHandler instance for this AsynchChannel |
boolean |
isClosed()
|
boolean |
isCloseFinished()
|
boolean |
isCloseStarted()
|
boolean |
isConnected()
|
boolean |
isOpened()
|
OpRead |
read_n(java.nio.ByteBuffer buf,
AsynchReadHandler handler)
Request to execute non-partitional read. |
OpRead |
read(java.nio.ByteBuffer buf,
AsynchReadHandler handler)
Request for read operation. |
OpTimer |
schedulerTimer(long delay,
AsynchTimerHandler handler)
Schedules timeout action to be called back on the associated AsynchHandler instance. |
AsynchChannelHandler |
setChannelHandler(AsynchChannelHandler handler)
|
protected boolean |
setClosing()
|
protected boolean |
setConnected()
|
protected abstract void |
startAccept(OpAccept op)
|
protected abstract boolean |
startClose()
|
protected abstract void |
startConnect(OpConnect op)
|
protected abstract void |
startRead(OpRead op)
|
abstract void |
startTimer(OpTimer op)
|
protected abstract void |
startWrite(OpWrite op)
|
OpWrite |
write_n(java.nio.ByteBuffer buf,
AsynchWriteHandler handler)
Request to execute non-partitional write. |
OpWrite |
write(java.nio.ByteBuffer buf,
AsynchWriteHandler handler)
Requets for write operation. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.util.concurrent.locks.ReentrantLock m_lock
protected AsynchChannel.State m_channelState
protected java.util.concurrent.ConcurrentLinkedQueue<IOOperation> m_readQue
protected java.util.concurrent.ConcurrentLinkedQueue<IOOperation> m_writeQue
public IOStatistic m_readInfo
public IOStatistic m_writeInfo
Constructor Detail |
---|
public AsynchChannel()
AsynchChannel
instance given specified
Demultiplexor
, AsynchHandler
and
SelectableChannel
instances.
m
- Demultiplexor
instance this m_asynchChannel works withp
- AsynchHandler
protocol instancesc
- SelectableChannel
instance this m_asynchChannel operates onMethod Detail |
---|
public AsynchChannelHandler setChannelHandler(AsynchChannelHandler handler)
public AsynchChannelHandler getChannelHandler()
protected abstract void startRead(OpRead op) throws java.lang.Exception
java.lang.Exception
protected abstract void startWrite(OpWrite op) throws java.lang.Exception
java.lang.Exception
protected abstract void startAccept(OpAccept op) throws java.lang.Exception
java.lang.Exception
protected abstract void startConnect(OpConnect op) throws java.lang.Exception
java.lang.Exception
public abstract void startTimer(OpTimer op) throws java.lang.Exception
java.lang.Exception
protected abstract boolean startClose()
protected boolean checkForClose()
protected abstract int finishRead(OpRead op) throws java.lang.Exception
op
-
java.lang.Exception
protected abstract int finishWrite(OpWrite op) throws java.lang.Exception
op
-
java.lang.Exception
protected abstract AsynchChannel finishAccept(OpAccept op) throws java.lang.Exception
op
-
java.lang.Exception
protected abstract boolean finishConnect(OpConnect op) throws java.lang.Exception
op
-
java.lang.Exception
protected boolean dispatchCompletions(java.util.concurrent.ConcurrentLinkedQueue<IOOperation> completedQue)
completedQue
- protected IOOperation executeListAndDispatch(java.util.concurrent.ConcurrentLinkedQueue<IOOperation> reqQue)
reqQue
-
protected IOOperation executeListAndAdd(java.util.concurrent.ConcurrentLinkedQueue<IOOperation> reqQue, boolean flgCancel, java.util.concurrent.ConcurrentLinkedQueue<IOOperation> completedQue)
reqQue
- completedQue
-
protected boolean executeOpAndAdd(IOOperation op, boolean flgCancel, java.util.concurrent.ConcurrentLinkedQueue<IOOperation> completedQue)
protected boolean executeOp(IOOperation op, boolean flgCancel)
protected void enqueueOperation(IOOperation op, java.util.concurrent.ConcurrentLinkedQueue<IOOperation> que, IOStatistic info) throws java.lang.Exception
java.lang.Exception
public OpRead read(java.nio.ByteBuffer buf, AsynchReadHandler handler) throws java.lang.Exception
buf
- buffer to read data to
exception
- if error occurs
java.lang.Exception
public OpRead read_n(java.nio.ByteBuffer buf, AsynchReadHandler handler) throws java.lang.Exception
Buffer.limit()
bytes to the buffer.
buf
-
exception
- if error occurs
java.lang.Exception
public OpWrite write(java.nio.ByteBuffer buf, AsynchWriteHandler handler) throws java.lang.Exception
buf
- buffer to write data from
exception
- if error occurs
java.lang.Exception
public OpWrite write_n(java.nio.ByteBuffer buf, AsynchWriteHandler handler) throws java.lang.Exception
Buffer.limit()
bytes to the associated channel.
buf
- buffer to write data from
exception
- if error occurs
java.lang.Exception
public OpAccept accept(AsynchAcceptHandler handler) throws java.lang.Exception
java.lang.Exception
- if error occurspublic OpConnect connect(java.net.SocketAddress addr, AsynchConnectHandler handler) throws java.lang.Exception
SocketAddress
- address to connect
java.lang.Exception
- if error occurspublic OpTimer schedulerTimer(long delay, AsynchTimerHandler handler) throws java.lang.Exception
AsynchHandler
instance.
Note: while IO operations will be delivered to the handler in a serialized way, timer notifications might be delivered concurrently.
delay
- delay in milliseconds before timeout action is to be executed.
java.lang.Exception
public void close()
public boolean isOpened()
public boolean isConnected()
public boolean isClosed()
public boolean isCloseStarted()
public boolean isCloseFinished()
protected final boolean setConnected()
protected final boolean setClosing()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |