Class SocketWrapperBase.OperationState<A>

  • Type Parameters:
    A - The attachment type
    All Implemented Interfaces:
    java.lang.Runnable
    Enclosing class:
    SocketWrapperBase<E>

    protected abstract class SocketWrapperBase.OperationState<A>
    extends java.lang.Object
    implements java.lang.Runnable
    Internal state tracker for vectored operations.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected A attachment
      Attachment object passed to the completion handler.
      protected SocketWrapperBase.BlockingMode block
      Blocking mode for the operation.
      protected java.nio.ByteBuffer[] buffers
      Buffers used for the vectored I/O operation.
      protected java.util.concurrent.atomic.AtomicBoolean callHandler
      Flag to ensure the completion handler is called only once.
      protected SocketWrapperBase.CompletionCheck check
      Completion check to determine handler invocation.
      protected SocketWrapperBase.VectoredIOCompletionHandler<A> completion
      Vectored I/O completion handler.
      protected boolean completionDone
      Indicates whether the vectored I/O completion processing is done.
      protected java.nio.channels.CompletionHandler<java.lang.Long,​? super A> handler
      Completion handler to invoke when the operation completes.
      protected int length
      Number of buffers in the operation.
      protected long nBytes
      Total number of bytes transferred by the operation.
      protected int offset
      Offset in the buffer array.
      protected boolean read
      Indicates whether this is a read operation.
      protected java.util.concurrent.Semaphore semaphore
      Semaphore for synchronizing concurrent operations.
      protected SocketWrapperBase.CompletionState state
      Current completion state of the operation.
      protected long timeout
      Timeout value for the operation.
      protected java.util.concurrent.TimeUnit unit
      Time unit for the timeout.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected void end()
      End the operation.
      protected boolean hasOutboundRemaining()
      Checks if there is remaining outbound data in the buffers.
      protected abstract boolean isInline()
      Determines whether the operation is still executing on the original caller thread.
      protected boolean process()
      Process the operation using the connector executor.
      protected void start()
      Start the operation, this will typically call run.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.lang.Runnable

        run
    • Field Detail

      • read

        protected final boolean read
        Indicates whether this is a read operation.
      • buffers

        protected final java.nio.ByteBuffer[] buffers
        Buffers used for the vectored I/O operation.
      • offset

        protected final int offset
        Offset in the buffer array.
      • length

        protected final int length
        Number of buffers in the operation.
      • attachment

        protected final A attachment
        Attachment object passed to the completion handler.
      • timeout

        protected final long timeout
        Timeout value for the operation.
      • unit

        protected final java.util.concurrent.TimeUnit unit
        Time unit for the timeout.
      • handler

        protected final java.nio.channels.CompletionHandler<java.lang.Long,​? super A> handler
        Completion handler to invoke when the operation completes.
      • semaphore

        protected final java.util.concurrent.Semaphore semaphore
        Semaphore for synchronizing concurrent operations.
      • callHandler

        protected final java.util.concurrent.atomic.AtomicBoolean callHandler
        Flag to ensure the completion handler is called only once.
      • nBytes

        protected volatile long nBytes
        Total number of bytes transferred by the operation.
      • completionDone

        protected boolean completionDone
        Indicates whether the vectored I/O completion processing is done.
    • Constructor Detail

      • OperationState

        protected OperationState​(boolean read,
                                 java.nio.ByteBuffer[] buffers,
                                 int offset,
                                 int length,
                                 SocketWrapperBase.BlockingMode block,
                                 long timeout,
                                 java.util.concurrent.TimeUnit unit,
                                 A attachment,
                                 SocketWrapperBase.CompletionCheck check,
                                 java.nio.channels.CompletionHandler<java.lang.Long,​? super A> handler,
                                 java.util.concurrent.Semaphore semaphore,
                                 SocketWrapperBase.VectoredIOCompletionHandler<A> completion)
        Creates a new operation state for a vectored I/O operation.
        Parameters:
        read - Whether this is a read operation
        buffers - The buffers for the operation
        offset - The offset in the buffer array
        length - The number of buffers
        block - The blocking mode
        timeout - The timeout duration
        unit - The timeout time unit
        attachment - An attachment object
        check - The completion check
        handler - The completion handler
        semaphore - The semaphore for synchronization
        completion - The vectored I/O completion handler
    • Method Detail

      • isInline

        protected abstract boolean isInline()
        Determines whether the operation is still executing on the original caller thread.
        Returns:
        true if the operation is still inline, false if running on a separate thread
      • hasOutboundRemaining

        protected boolean hasOutboundRemaining()
        Checks if there is remaining outbound data in the buffers.
        Returns:
        false by default; overridden by NIO implementations
      • process

        protected boolean process()
        Process the operation using the connector executor.
        Returns:
        true if the operation was accepted, false if the executor rejected execution
      • start

        protected void start()
        Start the operation, this will typically call run.
      • end

        protected void end()
        End the operation.