SocketWrapperBase.OperationState (Apache Tomcat 10.1.57 API Documentation)
Description: declaration: package: org.apache.tomcat.util.net, class: SocketWrapperBase, class: OperationState

# Class SocketWrapperBase.OperationState<A>

java.lang.Object
org.apache.tomcat.util.net.SocketWrapperBase.OperationState<A>

Type Parameters:
  `A` - The attachment type

All Implemented Interfaces:
  `Runnable`

Enclosing class:
  `SocketWrapperBase<E>`

protected abstract class SocketWrapperBase.OperationState<A> extends Object implements Runnable
Internal state tracker for vectored operations.

- ## Field Summary

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

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `OperationState(boolean read, ByteBuffer[] buffers, int offset, int length, SocketWrapperBase.BlockingMode block, long timeout, TimeUnit unit, A attachment, SocketWrapperBase.CompletionCheck check, CompletionHandler<Long, ? super A> handler, Semaphore semaphore, SocketWrapperBase<E>.VectoredIOCompletionHandler<A> completion)`
  Creates a new operation state for a vectored I/O operation.

- ## Method Summary

  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 Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface Runnable

  `run`

- ## Field Details

  - ### read

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

  - ### buffers

    protected final 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 TimeUnit unit
    Time unit for the timeout.

  - ### block

    protected final SocketWrapperBase.BlockingMode block
    Blocking mode for the operation.

  - ### check

    protected final SocketWrapperBase.CompletionCheck check
    Completion check to determine handler invocation.

  - ### handler

    protected final CompletionHandler<Long, ? super A> handler
    Completion handler to invoke when the operation completes.

  - ### semaphore

    protected final Semaphore semaphore
    Semaphore for synchronizing concurrent operations.

  - ### completion

    protected final SocketWrapperBase<E>.VectoredIOCompletionHandler<A> completion
    Vectored I/O completion handler.

  - ### callHandler

    protected final 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.

  - ### state

    protected volatile SocketWrapperBase.CompletionState state
    Current completion state of the operation.

  - ### completionDone

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

- ## Constructor Details

  - ### OperationState

    protected OperationState(boolean read, ByteBuffer[] buffers, int offset, int length, SocketWrapperBase.BlockingMode block, long timeout, TimeUnit unit, A attachment, SocketWrapperBase.CompletionCheck check, CompletionHandler<Long, ? super A> handler, Semaphore semaphore, SocketWrapperBase<E>.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 Details

  - ### 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.