java.lang.Object
io.helidon.common.socket.SocketWriter
- All Implemented Interfaces:
DataWriter
Socket writer (possibly) used from multiple threads, takes care of writing to a single
socket.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close this writer.static SocketWriter
create
(HelidonSocket socket) Create a new socket writer.static SocketWriter
create
(ExecutorService executor, HelidonSocket socket, int writeQueueLength) Create a new socket writer.protected HelidonSocket
socket()
Provides access to the underlying socket.void
writeNow
(BufferData buffer) Write buffer to underlying transport blocking until the buffer is written.void
writeNow
(BufferData... buffers) Write buffers to underlying transport blocking until the buffers are written.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.helidon.common.buffers.DataWriter
write, write
-
Constructor Details
-
SocketWriter
A new socket writer.- Parameters:
socket
- socket to write to
-
-
Method Details
-
create
public static SocketWriter create(ExecutorService executor, HelidonSocket socket, int writeQueueLength) Create a new socket writer.- Parameters:
executor
- executor used to create a thread for asynchronous writessocket
- socket to write towriteQueueLength
- maximal number of queued writes, write operation will block if the queue is full; if set to {code 1} or lower, write queue is disabled and writes are direct to socket (blocking)- Returns:
- a new socket writer
-
create
Create a new socket writer.- Parameters:
socket
- socket to write to- Returns:
- a new socket writer
-
writeNow
Description copied from interface:DataWriter
Write buffers to underlying transport blocking until the buffers are written.- Specified by:
writeNow
in interfaceDataWriter
- Parameters:
buffers
- buffers to write
-
writeNow
Description copied from interface:DataWriter
Write buffer to underlying transport blocking until the buffer is written.- Specified by:
writeNow
in interfaceDataWriter
- Parameters:
buffer
- buffer to write
-
close
public void close()Close this writer. Will attempt to write all enqueued buffers and will stop the thread if created. Does not close the socket. -
socket
Provides access to the underlying socket.- Returns:
- socket
-