APIdia Launch Partner
Top Description Fields Constructors Methods
sun.nio.ch

pack-priv abstract Class AsynchronousChannelGroupImpl

extends AsynchronousChannelGroup
implements Executor
Class Inheritance
All Implemented Interfaces
java.util.concurrent.Executor
Known Direct Subclasses
sun.nio.ch.Port
Imports
java.nio.channels.Channel, .AsynchronousChannelGroup, java.nio.channels.spi.AsynchronousChannelProvider, java.io.IOException, .FileDescriptor, java.util.Objects, .Queue, java.util.concurrent.*, java.util.concurrent.atomic.AtomicInteger, .AtomicBoolean

Base implementation of AsynchronousChannelGroup

Field Summary

Modifier and TypeField and Description
private static final int
private final ThreadPool
private final AtomicBoolean
private final Object
private final Queue<Runnable>
private volatile boolean
private final AtomicInteger
private final ScheduledThreadPoolExecutor

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv abstract Object
attachForeignChannel(Channel channel, FileDescriptor fdo)

Attaches a foreign channel to this group.

public final boolean
awaitTermination(long timeout, TimeUnit unit)

Implements abstract java.nio.channels.AsynchronousChannelGroup.awaitTermination.

Awaits termination of the group.

private Runnable
bindToGroup(final Runnable task)

pack-priv abstract void
closeAllChannels()

Closes all channels in the group

pack-priv abstract void
detachForeignChannel(Object key)

Detaches a foreign channel from this group.

pack-priv final void
detachFromThreadPool()

For use by AsynchronousFileChannel to release resources without shutting down the thread pool.

public final void
execute(Runnable task)

Implements java.util.concurrent.Executor.execute.

Executes the given command on one of the channel group's pooled threads.

pack-priv abstract void
executeOnHandlerTask(Runnable task)

Wakes up a thread waiting for I/O events to execute the given task.

pack-priv final void
executeOnPooledThread(Runnable task)

For a fixed thread pool the task is queued to a thread waiting on I/O events.

pack-priv final ExecutorService
pack-priv final int
pack-priv abstract boolean
isEmpty()

Returns true if there are no channels in the group

pack-priv final boolean
public final boolean
isShutdown()

Implements abstract java.nio.channels.AsynchronousChannelGroup.isShutdown.

Tells whether or not this asynchronous channel group is shutdown.

public final boolean
isTerminated()

Implements abstract java.nio.channels.AsynchronousChannelGroup.isTerminated.

Tells whether or not this group has terminated.

pack-priv final void
pack-priv final Runnable
pack-priv final Future<?>
schedule(Runnable task, long timeout, TimeUnit unit)

public final void
shutdown()

Implements abstract java.nio.channels.AsynchronousChannelGroup.shutdown.

Initiates an orderly shutdown of the group.

private void
pack-priv abstract void
shutdownHandlerTasks()

Shutdown all tasks waiting for I/O events.

public final void
shutdownNow()

Implements abstract java.nio.channels.AsynchronousChannelGroup.shutdownNow.

Shuts down the group and closes all open channels in the group.

private void
protected final void
pack-priv final int
pack-priv final int
threadExit(Runnable task, boolean replaceMe)

Invoked by tasks as they terminate

Inherited from java.nio.channels.AsynchronousChannelGroup:
providerwithCachedThreadPoolwithFixedThreadPoolwithThreadPool

Field Detail

internalThreadCountback to summary
private static final int internalThreadCount
poolback to summary
private final ThreadPool pool
shutdownback to summary
private final AtomicBoolean shutdown
shutdownNowLockback to summary
private final Object shutdownNowLock
taskQueueback to summary
private final Queue<Runnable> taskQueue
terminateInitiatedback to summary
private volatile boolean terminateInitiated
threadCountback to summary
private final AtomicInteger threadCount
timeoutExecutorback to summary
private final ScheduledThreadPoolExecutor timeoutExecutor

Constructor Detail

AsynchronousChannelGroupImplback to summary
pack-priv AsynchronousChannelGroupImpl(AsynchronousChannelProvider provider, ThreadPool pool)

Method Detail

attachForeignChannelback to summary
pack-priv abstract Object attachForeignChannel(Channel channel, FileDescriptor fdo) throws IOException

Attaches a foreign channel to this group.

awaitTerminationback to summary
public final boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException

Implements abstract java.nio.channels.AsynchronousChannelGroup.awaitTermination.

Doc from java.nio.channels.AsynchronousChannelGroup.awaitTermination.

Awaits termination of the group.

This method blocks until the group has terminated, or the timeout occurs, or the current thread is interrupted, whichever happens first.

Annotations
@Override
Exceptions
InterruptedException:
If interrupted while waiting
bindToGroupback to summary
private Runnable bindToGroup(final Runnable task)
closeAllChannelsback to summary
pack-priv abstract void closeAllChannels() throws IOException

Closes all channels in the group

detachForeignChannelback to summary
pack-priv abstract void detachForeignChannel(Object key)

Detaches a foreign channel from this group.

detachFromThreadPoolback to summary
pack-priv final void detachFromThreadPool()

For use by AsynchronousFileChannel to release resources without shutting down the thread pool.

executeback to summary
public final void execute(Runnable task)

Implements java.util.concurrent.Executor.execute.

Executes the given command on one of the channel group's pooled threads.

Annotations
@Override
executeOnHandlerTaskback to summary
pack-priv abstract void executeOnHandlerTask(Runnable task)

Wakes up a thread waiting for I/O events to execute the given task.

executeOnPooledThreadback to summary
pack-priv final void executeOnPooledThread(Runnable task)

For a fixed thread pool the task is queued to a thread waiting on I/O events. For other thread pools we simply submit the task to the thread pool.

executorback to summary
pack-priv final ExecutorService executor()
fixedThreadCountback to summary
pack-priv final int fixedThreadCount()
isEmptyback to summary
pack-priv abstract boolean isEmpty()

Returns true if there are no channels in the group

isFixedThreadPoolback to summary
pack-priv final boolean isFixedThreadPool()
isShutdownback to summary
public final boolean isShutdown()

Implements abstract java.nio.channels.AsynchronousChannelGroup.isShutdown.

Doc from java.nio.channels.AsynchronousChannelGroup.isShutdown.

Tells whether or not this asynchronous channel group is shutdown.

Annotations
@Override
isTerminatedback to summary
public final boolean isTerminated()

Implements abstract java.nio.channels.AsynchronousChannelGroup.isTerminated.

Doc from java.nio.channels.AsynchronousChannelGroup.isTerminated.

Tells whether or not this group has terminated.

Where this method returns true, then the associated thread pool has also terminated.

Annotations
@Override
offerTaskback to summary
pack-priv final void offerTask(Runnable task)
pollTaskback to summary
pack-priv final Runnable pollTask()
scheduleback to summary
pack-priv final Future<?> schedule(Runnable task, long timeout, TimeUnit unit)
shutdownback to summary
public final void shutdown()

Implements abstract java.nio.channels.AsynchronousChannelGroup.shutdown.

Doc from java.nio.channels.AsynchronousChannelGroup.shutdown.

Initiates an orderly shutdown of the group.

This method marks the group as shutdown. Further attempts to construct channel that binds to this group will throw ShutdownChannelGroupException. The group terminates when all asynchronous channels in the group are closed, all actively executing completion handlers have run to completion, and all resources have been released. This method has no effect if the group is already shutdown.

Annotations
@Override
shutdownExecutorsback to summary
private void shutdownExecutors()
shutdownHandlerTasksback to summary
pack-priv abstract void shutdownHandlerTasks()

Shutdown all tasks waiting for I/O events.

shutdownNowback to summary
public final void shutdownNow() throws IOException

Implements abstract java.nio.channels.AsynchronousChannelGroup.shutdownNow.

Doc from java.nio.channels.AsynchronousChannelGroup.shutdownNow.

Shuts down the group and closes all open channels in the group.

In addition to the actions performed by the shutdown method, this method invokes the close method on all open channels in the group. This method does not attempt to stop or interrupt threads that are executing completion handlers. The group terminates when all actively executing completion handlers have run to completion and all resources have been released. This method may be invoked at any time. If some other thread has already invoked it, then another invocation will block until the first invocation is complete, after which it will return without effect.

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
startInternalThreadback to summary
private void startInternalThread(final Runnable task)
startThreadsback to summary
protected final void startThreads(Runnable task)
threadCountback to summary
pack-priv final int threadCount()
threadExitback to summary
pack-priv final int threadExit(Runnable task, boolean replaceMe)

Invoked by tasks as they terminate