Package tlschannel.async
Class AsynchronousTlsChannelGroup
java.lang.Object
tlschannel.async.AsynchronousTlsChannelGroup
This class encapsulates the infrastructure for running
AsynchronousTlsChannels. Each
instance of this class is a singleton-like object that manages a thread pool that makes it
possible to run a group of asynchronous channels.-
Constructor Summary
ConstructorsConstructorDescriptionCreates an instance of this class, using as many thread as available processors.AsynchronousTlsChannelGroup(int nThreads) Creates an instance of this class. -
Method Summary
Modifier and TypeMethodDescriptionbooleanawaitTermination(long timeout, TimeUnit unit) Blocks until all registers sockets are closed and pending tasks finished execution after a shutdown request, or the timeout occurs, or the current thread is interrupted, whichever happens first.longReturn the total number of read operations that were cancelled.longReturn the total number of write operations that were cancelled.longReturns the current number of active read operations.longReturns the current number of registered sockets.longReturns the current number of active write operations.longReturn the total number of read operations that failed.longReturn the total number of write operations that failed.longReturn the total number of read operations that were started.longReturn the total number of write operations that were started.longReturn the total number of read operations that succeeded.longReturn the total number of write operations that succeeded.booleanisAlive()Returns whether the selector thread is alive (used for debugging).booleanWhether eithershutdown()orshutdownNow()have been called.booleanWhether this channel group was shut down, and all pending tasks have drained.voidshutdown()Starts the shutdown process.voidShuts down this channel group immediately.
-
Constructor Details
-
AsynchronousTlsChannelGroup
public AsynchronousTlsChannelGroup(int nThreads) Creates an instance of this class.- Parameters:
nThreads- number of threads in the executor used to assist the selector loop and run completion handlers.
-
AsynchronousTlsChannelGroup
public AsynchronousTlsChannelGroup()Creates an instance of this class, using as many thread as available processors.
-
-
Method Details
-
isShutdown
public boolean isShutdown()Whether eithershutdown()orshutdownNow()have been called.- Returns:
trueif this group has initiated shutdown andfalseif the group is active
-
shutdown
public void shutdown()Starts the shutdown process. New sockets cannot be registered, already registered one continue operating normally until they are closed. -
shutdownNow
public void shutdownNow()Shuts down this channel group immediately. All registered sockets are closed, pending operations may or may not finish. -
isTerminated
public boolean isTerminated()Whether this channel group was shut down, and all pending tasks have drained.- Returns:
- whether the channel is terminated
-
awaitTermination
Blocks until all registers sockets are closed and pending tasks finished execution after a shutdown request, or the timeout occurs, or the current thread is interrupted, whichever happens first.- Parameters:
timeout- the maximum time to waitunit- the time unit of the timeout argument- Returns:
trueif this group terminated andfalseif the group elapsed before termination- Throws:
InterruptedException- if interrupted while waiting
-
getStartedReadCount
public long getStartedReadCount()Return the total number of read operations that were started.- Returns:
- number of operations
-
getStartedWriteCount
public long getStartedWriteCount()Return the total number of write operations that were started.- Returns:
- number of operations
-
getSuccessfulReadCount
public long getSuccessfulReadCount()Return the total number of read operations that succeeded.- Returns:
- number of operations
-
getSuccessfulWriteCount
public long getSuccessfulWriteCount()Return the total number of write operations that succeeded.- Returns:
- number of operations
-
getFailedReadCount
public long getFailedReadCount()Return the total number of read operations that failed.- Returns:
- number of operations
-
getFailedWriteCount
public long getFailedWriteCount()Return the total number of write operations that failed.- Returns:
- number of operations
-
getCancelledReadCount
public long getCancelledReadCount()Return the total number of read operations that were cancelled.- Returns:
- number of operations
-
getCancelledWriteCount
public long getCancelledWriteCount()Return the total number of write operations that were cancelled.- Returns:
- number of operations
-
getCurrentReadCount
public long getCurrentReadCount()Returns the current number of active read operations.- Returns:
- number of operations
-
getCurrentWriteCount
public long getCurrentWriteCount()Returns the current number of active write operations.- Returns:
- number of operations
-
getCurrentRegistrationCount
public long getCurrentRegistrationCount()Returns the current number of registered sockets.- Returns:
- number of sockets
-
isAlive
public boolean isAlive()Returns whether the selector thread is alive (used for debugging).- Returns:
- whether the selector thread is alive
-