final class StreamConnectionIO extends ConnectionIO
Modifier and Type | Class and Description |
---|---|
private class |
StreamConnectionIO.Reader |
private class |
StreamConnectionIO.Writer |
Modifier and Type | Field and Description |
---|---|
private InputStream |
in |
private ReadableByteChannel |
inChannel |
private ByteBuffer |
inputBuffer
buffer for reading incoming data from connection
|
private static Logger |
logger
mux logger
|
private OutputStream |
out
I/O streams for underlying connection
|
private WritableByteChannel |
outChannel
channels wrapped around underlying I/O streams
|
private static int |
RECEIVE_BUFFER_SIZE |
private LinkedList |
sendQueue
queue of buffers of data to be sent over connection, interspersed
with IOFuture objects that need to be notified in sequence
|
private static Executor |
systemThreadPool
pool of threads for executing tasks in system thread group:
used for I/O (reader and writer) threads
|
mux
Constructor and Description |
---|
StreamConnectionIO(Mux mux,
OutputStream out,
InputStream in)
Creates a new StreamConnectionIO for the connection represented by
the supplied OutputStream and InputStream pair.
|
Modifier and Type | Method and Description |
---|---|
(package private) void |
asyncSend(ByteBuffer buffer)
Sends the sequence of bytes contained in the supplied buffer to the
underlying connection.
|
(package private) void |
asyncSend(ByteBuffer first,
ByteBuffer second)
Sends the sequence of bytes contained in the supplied buffers to the
underlying connection.
|
private void |
drainQueue(LinkedList queue) |
(package private) IOFuture |
futureSend(ByteBuffer first,
ByteBuffer second)
Sends the sequence of bytes contained in the supplied buffers to the
underlying connection.
|
static ReadableByteChannel |
newChannel(InputStream in)
The following two methods are modifications of their
equivalents in java.nio.channels.Channels with the assumption
that the supplied byte buffers are backed by arrays, so no
additional copying is required.
|
static WritableByteChannel |
newChannel(OutputStream out) |
(package private) void |
start()
Starts processing connection data.
|
private static final int RECEIVE_BUFFER_SIZE
private static final Executor systemThreadPool
private static final Logger logger
private final OutputStream out
private final InputStream in
private final WritableByteChannel outChannel
private final ReadableByteChannel inChannel
private LinkedList sendQueue
private final ByteBuffer inputBuffer
StreamConnectionIO(Mux mux, OutputStream out, InputStream in)
void start() throws IOException
start
in class ConnectionIO
IOException
void asyncSend(ByteBuffer buffer)
ConnectionIO
asyncSend
in class ConnectionIO
void asyncSend(ByteBuffer first, ByteBuffer second)
ConnectionIO
asyncSend
in class ConnectionIO
IOFuture futureSend(ByteBuffer first, ByteBuffer second)
ConnectionIO
futureSend
in class ConnectionIO
private void drainQueue(LinkedList queue)
public static ReadableByteChannel newChannel(InputStream in)
public static WritableByteChannel newChannel(OutputStream out)
Copyright 2007-2013, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.