public class BIONetworkLayer extends NetworkLayer
NetworkLayer that uses a dedicated reader thread and runs on demand writer thread to manage I/O.ProtocolLayer.Recv, ProtocolLayer.SendEMPTY_BUFFER| Constructor and Description |
|---|
BIONetworkLayer(IOHub ioHub,
ReadableByteChannel in,
WritableByteChannel out)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
doCloseRecv()
Request the recv side to be closed.
|
void |
doCloseSend()
Notify the lower layer that it should close.
|
boolean |
isSendOpen()
Tracks if this layer is submitting data to be sent via
ProtocolLayer.Send.doSend(ByteBuffer). |
void |
start()
Starts this layer.
|
protected void |
write(ByteBuffer data)
SPI: Perform the actual write to the recipient.
|
acquire, doSend, getIoHub, init, isRecvOpen, newByteBufferQueue, onRead, onRecvClosed, release, stackpublic BIONetworkLayer(IOHub ioHub, ReadableByteChannel in, WritableByteChannel out)
ioHub - our hub.in - the source of data.out - the sink for data.protected void write(@NonNull
ByteBuffer data)
throws IOException
write in class NetworkLayerdata - the data received. Any data consumed from the ByteBuffer can be assumed as processed.
Any data not consumed from the ByteBuffer will be the responsibility of the caller
to resubmit in subsequent calls.IOException - if something goes wrongpublic void doCloseRecv()
doCloseRecv in class NetworkLayerpublic void start()
throws IOException
start in interface ProtocolLayerstart in class NetworkLayerIOException - if something goes wrong.public void doCloseSend()
throws IOException
ProtocolLayer.Recv.onRecvClosed(IOException) for any upper layers.IOException - if there was an error closing the lower layer.public boolean isSendOpen()
ProtocolLayer.Send.doSend(ByteBuffer).
Once this method returns false it must always return false and can be assumed to behave in
this way.true if submitting data to be sent via ProtocolLayer.Send.doSend(ByteBuffer).Copyright © 2004–2022. All rights reserved.