Class SocketWriter

java.lang.Object
io.helidon.common.socket.SocketWriter
All Implemented Interfaces:
DataWriter

public abstract class SocketWriter extends Object implements DataWriter
Socket writer (possibly) used from multiple threads, takes care of writing to a single socket.
  • Constructor Details

    • SocketWriter

      protected SocketWriter(HelidonSocket socket)
      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 writes
      socket - socket to write to
      writeQueueLength - 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

      public static SocketWriter create(HelidonSocket socket)
      Create a new socket writer.
      Parameters:
      socket - socket to write to
      Returns:
      a new socket writer
    • writeNow

      public void writeNow(BufferData... buffers)
      Description copied from interface: DataWriter
      Write buffers to underlying transport blocking until the buffers are written.
      Specified by:
      writeNow in interface DataWriter
      Parameters:
      buffers - buffers to write
    • writeNow

      public void writeNow(BufferData buffer)
      Description copied from interface: DataWriter
      Write buffer to underlying transport blocking until the buffer is written.
      Specified by:
      writeNow in interface DataWriter
      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

      protected HelidonSocket socket()
      Provides access to the underlying socket.
      Returns:
      socket