public final class SelectionManager extends Object
This implementation uses the Logger
named
com.sun.jini.jeri.internal.runtime.SelectionManager
to
log information at the following levels:
Level | Description |
---|---|
HANDLED | I/O exception caught from select operation |
Modifier and Type | Class and Description |
---|---|
class |
SelectionManager.Key
A Key represents a given SelectableChannel's registration with this
SelectionManager.
|
static interface |
SelectionManager.SelectionHandler
SelectionHandler is the callback interface for an object that will
process an I/O readiness event that has been detected by a
SelectionManager.
|
private class |
SelectionManager.SelectLoop
SelectLoop provides the main loop for each I/O processing thread.
|
Modifier and Type | Field and Description |
---|---|
private static int |
concurrency
number of concurrent I/O processing threads
|
private Object |
lock
lock guarding selectingThread, wakeupPending, renewQueue, readyQueue,
renewMaskRef, and mutable state of all Key instances.
|
private static Logger |
logger |
private SelectionManager.Key |
readyQueue
queue of keys that have I/O operations ready to be handled
|
private Map |
registeredChannels
set of registered channels, to detect duplicate registrations
|
private int[] |
renewMaskRef
holder used for pass-by-reference invocations
|
private SelectionManager.Key |
renewQueue
queue of keys that need to have interest masks updated
|
private Thread |
selectingThread
thread with exclusive right to perform a select operation, if any
|
private Selector |
selector
shared Selector used by this SelectionManager
|
private static Executor |
systemThreadPool
pool of threads for executing tasks in system thread group
|
private ByteBuffer |
wakeupBuffer |
private boolean |
wakeupPending
true if a wakeup has been requested but not yet processed
|
private SelectionKey |
wakeupPipeKey |
private Pipe.SinkChannel |
wakeupPipeSink
internal pipe used to wake up a blocked select operation
|
private Pipe.SourceChannel |
wakeupPipeSource |
Constructor and Description |
---|
SelectionManager()
Creates a new SelectionManager.
|
Modifier and Type | Method and Description |
---|---|
private void |
addOrUpdateReadyQueue(SelectionManager.Key key,
int newReadyMask) |
private void |
addOrUpdateRenewQueue(SelectionManager.Key key,
int newRenewMask) |
private void |
drainWakeupPipe() |
private boolean |
isReadyQueueEmpty() |
private boolean |
isRenewQueueEmpty() |
private void |
processRenewQueue()
In preparation for performing a select operation, process all new
and renewed interest registrations so that current SelectionKey
interest masks are up to date.
|
SelectionManager.Key |
register(SelectableChannel channel,
SelectionManager.SelectionHandler handler)
Registers the given SelectableChannel with this SelectionManager.
|
private SelectionManager.Key |
removeFromReadyQueue(int[] readyMaskOut) |
private SelectionManager.Key |
removeFromRenewQueue(int[] renewMaskOut) |
private SelectionManager.Key |
waitForReadyKey(int[] readyMaskOut)
Waits until one of the registered channels is ready for one or more
I/O operations.
|
private void |
wakeupSelector() |
private static final int concurrency
private static final Logger logger
private static final Executor systemThreadPool
private final Selector selector
private final Pipe.SinkChannel wakeupPipeSink
private final Pipe.SourceChannel wakeupPipeSource
private final SelectionKey wakeupPipeKey
private final ByteBuffer wakeupBuffer
private final Map registeredChannels
private final Object lock
private Thread selectingThread
private boolean wakeupPending
private SelectionManager.Key renewQueue
private SelectionManager.Key readyQueue
private final int[] renewMaskRef
public SelectionManager() throws IOException
IOException
public SelectionManager.Key register(SelectableChannel channel, SelectionManager.SelectionHandler handler)
private SelectionManager.Key waitForReadyKey(int[] readyMaskOut) throws InterruptedException
InterruptedException
private void wakeupSelector()
private void drainWakeupPipe()
private void processRenewQueue()
private boolean isRenewQueueEmpty()
private SelectionManager.Key removeFromRenewQueue(int[] renewMaskOut)
private void addOrUpdateRenewQueue(SelectionManager.Key key, int newRenewMask)
private boolean isReadyQueueEmpty()
private SelectionManager.Key removeFromReadyQueue(int[] readyMaskOut)
private void addOrUpdateReadyQueue(SelectionManager.Key key, int newReadyMask)
Copyright 2007-2013, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.