pyrasun.eio
Interface EIOWorker
- All Known Implementing Classes:
- EIOAcceptWorkerFactory.EIOAcceptingWorker, EIOByteArrayReader, EIOByteArrayWriter, EIOObjectReader, EIOObjectWriter, EIOStringReader, EIOStringWriter, ObjectProcessor
- public interface EIOWorker
A worker that responds to and handles events. There are four pre-defined event
types which have some specific protocols on what 'object' and the return
value mean, and what the Endpoint really is:
- READ: 'object' will be null, return should be Object read in. For non-blocking
readers, it's legal to return null which indicates that you couldn't
complete a read. Endpoint will be a ReadWriteEndpoint.
- WRITE: 'object' will be the next object to write. For non-blocking writers, this
may be null if a previous write was incomplete. In that case, it's up to
the writer to remember write state and be able to pick up where it left off.
Before completion of the handleEvent method, the writer must setu
setIsWriteInProgress() on the endpoint to indicate whether or not
I/O completed. This is handled automatically if you are using
the default EIOOutputBuffer, if you're rolling your own buffer
management you'll have to do this manually. Endpoint will be a
ReadWriteEndpoint.
- PROCESS: 'object' will be the item to process. The return is ignored. Endpoint will
be a ReadWriteEndpoint.
- ACCEPT: 'object' is null and the return is ignored. You're expected here to just
call accept and create a new Endpoint. Endpoint will be an AcceptingEndpoint.
Note that readers, writers, and processors must obviously cooperate together on
what they're returning and processing.
getWorkerType
public EIOEvent getWorkerType()
handleEvent
public java.lang.Object handleEvent(EIOEvent event,
java.lang.Object object,
Endpoint endpoint)
throws java.io.IOException
- Throws:
java.io.IOException
Pyrasun EmberIO