Package org.apache.tomcat.util.net
Class SocketWrapperBase.OperationState<A>
- java.lang.Object
-
- org.apache.tomcat.util.net.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.RunnableInternal state tracker for vectored operations.
-
-
Field Summary
Fields Modifier and Type Field Description protected AattachmentAttachment object passed to the completion handler.protected SocketWrapperBase.BlockingModeblockBlocking mode for the operation.protected java.nio.ByteBuffer[]buffersBuffers used for the vectored I/O operation.protected java.util.concurrent.atomic.AtomicBooleancallHandlerFlag to ensure the completion handler is called only once.protected SocketWrapperBase.CompletionCheckcheckCompletion check to determine handler invocation.protected SocketWrapperBase.VectoredIOCompletionHandler<A>completionVectored I/O completion handler.protected booleancompletionDoneIndicates whether the vectored I/O completion processing is done.protected java.nio.channels.CompletionHandler<java.lang.Long,? super A>handlerCompletion handler to invoke when the operation completes.protected intlengthNumber of buffers in the operation.protected longnBytesTotal number of bytes transferred by the operation.protected intoffsetOffset in the buffer array.protected booleanreadIndicates whether this is a read operation.protected java.util.concurrent.SemaphoresemaphoreSemaphore for synchronizing concurrent operations.protected SocketWrapperBase.CompletionStatestateCurrent completion state of the operation.protected longtimeoutTimeout value for the operation.protected java.util.concurrent.TimeUnitunitTime unit for the timeout.
-
Constructor Summary
Constructors Modifier Constructor Description protectedOperationState(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.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidend()End the operation.protected booleanhasOutboundRemaining()Checks if there is remaining outbound data in the buffers.protected abstract booleanisInline()Determines whether the operation is still executing on the original caller thread.protected booleanprocess()Process the operation using the connector executor.protected voidstart()Start the operation, this will typically call 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.
-
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 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.
-
completion
protected final SocketWrapperBase.VectoredIOCompletionHandler<A> completion
Vectored I/O completion handler.
-
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.
-
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 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 operationbuffers- The buffers for the operationoffset- The offset in the buffer arraylength- The number of buffersblock- The blocking modetimeout- The timeout durationunit- The timeout time unitattachment- An attachment objectcheck- The completion checkhandler- The completion handlersemaphore- The semaphore for synchronizationcompletion- 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:
trueif the operation is still inline,falseif running on a separate thread
-
hasOutboundRemaining
protected boolean hasOutboundRemaining()
Checks if there is remaining outbound data in the buffers.- Returns:
falseby 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.
-
-