au.com.terabit.jproactor
Class IOOperation

java.lang.Object
  extended by au.com.terabit.jproactor.IOOperation
Direct Known Subclasses:
OpAccept, OpConnect, OpRead, OpWrite

public abstract class IOOperation
extends java.lang.Object

The IOOperation class defines commonality shared between all IO operations in the JavaProactor.

When operation can be executed in non-blocking manner TCPAsynchChannel calls IOoperation#execute() method to do IO operation. Once operation is executed multiplexor might query ask whether this operation is completed so the next operation, IOOperation#nextPossible(), if any, will be executed while TCPAsynchChannel is active for the channel.

Version:
$Revision$ $Date$
Author:
Alexander Libman, Yevgeny Libman

Field Summary
protected  AsynchChannel m_asynchChannel
          Operations' m_asynchChannel once operation is completed.
protected  java.lang.Exception m_errorCause
          Operations' error cause, if any
 
Constructor Summary
protected IOOperation(int type, AsynchChannel handler)
          Creates IOOperation instance.
 
Method Summary
protected abstract  boolean execute()
           
 AsynchChannel getChannel()
          Returns AsycnhChannel of this operation.
 java.lang.Exception getError()
          Returns last error during IO operation
 int getState()
          Returns operation's m_state
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_errorCause

protected java.lang.Exception m_errorCause
Operations' error cause, if any


m_asynchChannel

protected AsynchChannel m_asynchChannel
Operations' m_asynchChannel once operation is completed.

Constructor Detail

IOOperation

protected IOOperation(int type,
                      AsynchChannel handler)
Creates IOOperation instance.

Parameters:
m_type - IO operation m_type, where m_type is one of the following: OP_ACCEPT, OP_READ, OP_WRITE or OP_CONNECT
m_asynchChannel - TCPAsynchChannel instance
Method Detail

execute

protected abstract boolean execute()

getChannel

public AsynchChannel getChannel()
Returns AsycnhChannel of this operation.

Returns:
SelectableChannelinstance associated with this operation
See Also:
TCPAsynchChannel#getChannel()

getState

public int getState()
Returns operation's m_state

Returns:
one of the following states: STATE_FREE, STATE_QUEUED, STATE_STARTED, STATE_FINISHED or STATE_CANCELED

getError

public java.lang.Exception getError()
Returns last error during IO operation

Returns:
last error or null otherwise