pyrasun.eio
Class ReadWriteEndpoint

java.lang.Object
  extended bypyrasun.eio.Endpoint
      extended bypyrasun.eio.ReadWriteEndpoint
Direct Known Subclasses:
EIOByteArrayEndpoint, EIOObjectEndpoint

public class ReadWriteEndpoint
extends Endpoint

A ReadWriteEndpoint is an endpoint that represents a socket channel, but has been cleverly named "ReadWriteEndpoint" to befuddle and confuse you into thinking it's alot more impressive than it actually is.

In addition to the mechanisms it inherits from the abstract Endpoint class, ReadWriteEndpoint encapsulates the machinery for managing READ, PROCESS, and WRITE events. Specifically, it contains the following:


Constructor Summary
ReadWriteEndpoint(EndpointCoordinator coordinator, java.nio.channels.SocketChannel nioChannel)
          Construct a new ReadWriteEndpoint.
 
Method Summary
 void abortWrites()
          Evil, evil hack.
 void addToProcessing(java.lang.Object o)
          Adds a new Object to be available as input to a PROCESS event.
 boolean arePendingWrites()
          Returns true if there are objects sitting in the write queue.
 EIOInputBuffer getInputBuffer()
          Get the input buffer associated with this endpoint.
 java.nio.channels.SelectableChannel getNIOChannel()
          Get the NIO channel associated with this endpoint.
 EIOOutputBuffer getOutputBuffer()
          Get the output buffer associated with this endpoint.
 int getProcessingQueueDepth()
           
 int getWriteQueueDepth()
           
 boolean isWriteInProgress()
          Returns true if a write is in progress or a partial write was performed that needs to be taken care of at some later time.
 boolean isWriteQueueEmpty()
          Returns the true if the writing object queue is empty.
 boolean needsReadPause()
           
 java.lang.Object nextForProcessing()
          Returns the next Object available as input to a PROCESS event.
 java.lang.Object nextForWriting()
          Returns the next object available as input to a WRITE event.
 boolean noReadsForMe()
           
 boolean noWritesForMe()
           
 void processingDispatch(boolean meProc)
          If no one else is handling PROCESS on this right now, dispatch it for handling
 void readPause()
           
 void setIsWriteInProgress(boolean inProgress)
          If 'inProgress' is true, this indicates that a write is in progress right now and hasn't been completed yet.
 void write(java.lang.Object o)
          Tell EIO to write an object out on this Endpoint.
 
Methods inherited from class pyrasun.eio.Endpoint
addInterest, addProcessing, attach, attachment, close, close, close, close, close, configureBlocking, dumpProcessedStats, getContext, getCoordinator, getInterestEvents, getNIOInterestEvents, getProcessingEvents, getReadyEvents, getState, isAborted, isBlocking, isLockedForProcessing, isLockedReady, isOpen, isReady, isSelectorized, lockForEventManager, lockForProcessing, lockForReady, masksAsString, registerEventListener, removeInterest, removeProcessing, removeReadiness, reportReadError, reportWriteError, setName, setReadiness, setReadiness, toString, unlockProcessing, updateProcessedStats
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ReadWriteEndpoint

public ReadWriteEndpoint(EndpointCoordinator coordinator,
                         java.nio.channels.SocketChannel nioChannel)
Construct a new ReadWriteEndpoint. This generally happens when your socket server (er, I mean AcceptingEndpoint) accepts a new connection and needs to add it into EIO, or when a client successfully connects to a server.

Parameters:
coordinator - the EndpointCoordinator that defines that kind of Endpoint this is, and how to handle it.
nioChannel - The SocketChannel. evil evil evil for a generic beyond-NIO library!
Method Detail

getNIOChannel

public java.nio.channels.SelectableChannel getNIOChannel()
Description copied from class: Endpoint
Get the NIO channel associated with this endpoint. This method is wicked and evil in a library that purports to be greater than just NIO

Specified by:
getNIOChannel in class Endpoint

getInputBuffer

public EIOInputBuffer getInputBuffer()
Get the input buffer associated with this endpoint. The underlying buffer is created on-demand - if you want to do your own buffer management, knock yourself out, and you won't pay for having extra buffers hanging around within EmberIO so long as you don't call getInputBuffer(). The buffer you get is nice because it's automatically hooked into the whole EIO framework, and alot of nasty nasty business is automatically handled for you.


getOutputBuffer

public EIOOutputBuffer getOutputBuffer()
Get the output buffer associated with this endpoint. This buffer is created on-demand, so if you're a lunatic and want to do your own buffer management go right ahead, and you won't pay the cost of creating one of these. The buffer you get is nice because it's automatically hooked into the whole EIO framework, and alot of nasty nasty business is automatically handled for you.


nextForProcessing

public java.lang.Object nextForProcessing()
Returns the next Object available as input to a PROCESS event. End users should only call this if you're seriously subverting the EIO library and are trying to do some tremendous hack without Ember's knowledge or cooperation.


addToProcessing

public void addToProcessing(java.lang.Object o)
Adds a new Object to be available as input to a PROCESS event. End users should only call this if you're seriously subverting the EIO library and are trying to do some tremendous hack without Ember's knowledge or cooperation.


needsReadPause

public boolean needsReadPause()

readPause

public void readPause()

processingDispatch

public void processingDispatch(boolean meProc)
If no one else is handling PROCESS on this right now, dispatch it for handling


nextForWriting

public java.lang.Object nextForWriting()
Returns the next object available as input to a WRITE event. End users should only call this if you're seriously subverting the EIO library and are trying to do some tremendous hack without Ember's knowledge or cooperation.


getWriteQueueDepth

public int getWriteQueueDepth()

getProcessingQueueDepth

public int getProcessingQueueDepth()

isWriteQueueEmpty

public boolean isWriteQueueEmpty()
Returns the true if the writing object queue is empty. End users should only call this if you're seriously subverting the EIO library and are trying to do some tremendous hack without Ember's knowledge or cooperation.


write

public void write(java.lang.Object o)
           throws java.io.IOException
Tell EIO to write an object out on this Endpoint. NOTE: this write is asynchronous. You may never know if this actually works!

Throws:
java.io.IOException

setIsWriteInProgress

public void setIsWriteInProgress(boolean inProgress)
If 'inProgress' is true, this indicates that a write is in progress right now and hasn't been completed yet. End users need to use this if they are avoiding EIO's own buffer management and are rolling their own. In that case, call setIsWriteInProgress (true) if your WRITE EIOWorker couldn't complete a write, and call it with false if you finished a write before returning from the worker.


isWriteInProgress

public boolean isWriteInProgress()
Returns true if a write is in progress or a partial write was performed that needs to be taken care of at some later time.


arePendingWrites

public boolean arePendingWrites()
Returns true if there are objects sitting in the write queue.


abortWrites

public void abortWrites()
Evil, evil hack.


noWritesForMe

public boolean noWritesForMe()

noReadsForMe

public boolean noReadsForMe()


Pyrasun EmberIO