java.lang.Object
io.helidon.common.socket.SocketWriter
io.helidon.common.socket.SmartSocketWriter
- All Implemented Interfaces:
DataWriter,AutoCloseable
A special socket write that starts async but may switch to sync mode if it
detects that the async queue size is below
QUEUE_SIZE_THRESHOLD.
If it switches to sync mode, it shall never return back to async mode.
Regular write(BufferData) initially enqueues data so callers usually avoid direct
socket writes while the queue has capacity. If the async queue stays mostly empty, the writer
switches to synchronous writes to avoid the queueing and executor handoff cost on low-contention
connections.-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close this writer.voidflush()Flushes to the underlying transport any pending data that has been written using eitherDataWriter.write(BufferData)orDataWriter.write(BufferData...).voidwrite(BufferData buffer) Write buffer, may delay writing and may write on a different thread.voidwrite(BufferData... buffers) Write buffers, may delay writing and may write on a different thread.voidwriteNow(BufferData buffer) Write buffer to underlying transport blocking until the buffer is written.Methods inherited from class io.helidon.common.socket.SocketWriter
create, create, socket, writeNow
-
Method Details
-
write
Description copied from interface:DataWriterWrite buffers, may delay writing and may write on a different thread. This method also may combine multiple calls into a single write to the underlying transport.- Parameters:
buffers- buffers to write
-
write
Description copied from interface:DataWriterWrite buffer, may delay writing and may write on a different thread. This method also may combine multiple calls into a single write to the underlying transport.- Parameters:
buffer- buffer to write
-
writeNow
Description copied from interface:DataWriterWrite buffer to underlying transport blocking until the buffer is written.- Specified by:
writeNowin interfaceDataWriter- Overrides:
writeNowin classSocketWriter- Parameters:
buffer- buffer to write
-
flush
public void flush()Description copied from interface:DataWriterFlushes to the underlying transport any pending data that has been written using eitherDataWriter.write(BufferData)orDataWriter.write(BufferData...). -
close
public void close()Description copied from class:SocketWriterClose 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- Overrides:
closein classSocketWriter
-