public abstract class AbstractNIOAsyncQueueReader extends AbstractReader<SocketAddress> implements AsyncQueueReader<SocketAddress>
AsyncQueueReader implementation, based on the Java NIOAsyncQueue.AsyncResult| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_BUFFER_SIZE |
protected int |
defaultBufferSize |
protected NIOTransport |
transport |
COMPLETE_EVENT, INCOMPLETE_EVENT, READ_EVENTEXPECTING_MORE_OPTION| Constructor and Description |
|---|
AbstractNIOAsyncQueueReader(NIOTransport transport) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close AsyncQueueProcessor and release associated resources
|
protected int |
doRead(Connection connection,
AsyncReadQueueRecord queueRecord)
Performs real read on the NIO channel
|
boolean |
isReady(Connection connection)
Checks whether there is ready data in
AsyncQueue,
associated with the Connection. |
void |
onClose(Connection connection)
Callback method, which is called, when
Connection has been closed,
to let processor release a connection associated resources. |
protected void |
onReadFailure(Connection connection,
AsyncReadQueueRecord failedRecord,
IOException e) |
protected abstract void |
onReadyToRead(Connection connection) |
AsyncQueue.AsyncResult |
processAsync(Context context)
Callback method, which is called async.
|
void |
read(Connection<SocketAddress> connection,
Buffer buffer,
CompletionHandler<ReadResult<Buffer,SocketAddress>> completionHandler,
Interceptor<ReadResult> interceptor)
Method reads data to the buffer.
|
protected abstract int |
read0(Connection connection,
Buffer buffer,
ReadResult<Buffer,SocketAddress> currentResult) |
read, read, readpublic static final int DEFAULT_BUFFER_SIZE
protected int defaultBufferSize
protected final NIOTransport transport
public AbstractNIOAsyncQueueReader(NIOTransport transport)
public void read(Connection<SocketAddress> connection, Buffer buffer, CompletionHandler<ReadResult<Buffer,SocketAddress>> completionHandler, Interceptor<ReadResult> interceptor)
read in interface Reader<SocketAddress>connection - the Connection to read frombuffer - the Buffer to which data will be readcompletionHandler - CompletionHandler,
which will get notified, when read will be completedinterceptor - Interceptor, which will be able to intercept
control each time new portion of a data was read to a
buffer.
The interceptor can decide, whether asynchronous read is
completed or not, or provide other processing instructions.public final boolean isReady(Connection connection)
AsyncQueue,
associated with the Connection.isReady in interface AsyncQueueconnection - Connectionpublic AsyncQueue.AsyncResult processAsync(Context context)
AsyncQueue, which are associated with the given
ConnectionprocessAsync in interface AsyncQueuecontext - ContextAsyncQueue.AsyncResult, depending on async queue status.public void onClose(Connection connection)
Connection has been closed,
to let processor release a connection associated resources.onClose in interface AsyncQueueconnection - Connectionpublic final void close()
close in interface AsyncQueueprotected final int doRead(Connection connection, AsyncReadQueueRecord queueRecord) throws IOException
connection - the Connection to read fromqueueRecord - the record to be read toIOExceptionprotected final void onReadFailure(Connection connection, AsyncReadQueueRecord failedRecord, IOException e)
protected abstract int read0(Connection connection, Buffer buffer, ReadResult<Buffer,SocketAddress> currentResult) throws IOException
IOExceptionprotected abstract void onReadyToRead(Connection connection) throws IOException
IOExceptionCopyright © 2014 Oracle Corporation. All Rights Reserved.