java.lang.Object
io.helidon.common.socket.SocketWriter
- All Implemented Interfaces:
DataWriter,AutoCloseable
- Direct Known Subclasses:
SmartSocketWriter
Socket writer (possibly) used from multiple threads, takes care of writing to a single
socket.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close this writer.static SocketWritercreate(HelidonSocket socket) Create a new socket writer.static SocketWritercreate(ExecutorService executor, HelidonSocket socket, int writeQueueLength, boolean smartAsyncWrites) Create a new socket writer.protected HelidonSocketsocket()Provides access to the underlying socket.voidwriteNow(BufferData buffer) Write buffer to underlying transport blocking until the buffer is written.voidwriteNow(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, waitMethods inherited from interface io.helidon.common.buffers.DataWriter
flush, 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, boolean smartAsyncWrites) 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)smartAsyncWrites- flag to enable smart async writes, seeSmartSocketWriter- 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:DataWriterWrite buffers to underlying transport blocking until the buffers are written.- Specified by:
writeNowin interfaceDataWriter- Parameters:
buffers- buffers to write
-
writeNow
Description copied from interface:DataWriterWrite buffer to underlying transport blocking until the buffer is written.- Specified by:
writeNowin 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.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceDataWriter
-
socket
Provides access to the underlying socket.- Returns:
- socket
-