Top Inners Fields Constructors Methods
org.newsclub.net.unix

pack-priv final Class AFSelector

extends AbstractSelector
Class Inheritance
Imports
java.io.FileDescriptor, .IOException, java.net.SocketException, .SocketTimeoutException, java.nio.ByteBuffer, java.nio.channels.ClosedSelectorException, .SelectableChannel, .SelectionKey, .Selector, java.nio.channels.spi.AbstractSelectableChannel, .AbstractSelector, java.util.Collections, .Iterator, .Map, .Set, java.util.concurrent.ConcurrentHashMap, java.util.concurrent.atomic.AtomicInteger

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class

Field Summary

Modifier and TypeField and Description
private final Map<AFSelectionKey, Integer>
private final Set<AFSelectionKey>
private final Set<SelectionKey>
private final ByteBuffer
private final ByteBuffer
private AFSelector.PollFd
private final AtomicInteger
private final Set<SelectionKey>
private final MapValueSet<SelectionKey, Integer>
private final AFPipe
private final AFSelector.PollFd

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
private synchronized void
private void
protected void
private AFSelector.PollFd
initPollFd(AFSelector.PollFd existingPollFd)

public Set<SelectionKey>
keys()

Implements abstract java.nio.channels.Selector.keys.

Returns this selector's key set.

private int
receive(int maxReceive, int options)

protected SelectionKey
register(AbstractSelectableChannel
The channel to be registered
ch
,
int
The initial interest set, which must be valid
ops
,
Object
The initial attachment for the resulting key
att
)

Implements abstract java.nio.channels.spi.AbstractSelector.register.

Registers the given channel with this selector.

pack-priv synchronized void
public int
select(long
If positive, block for up to timeout milliseconds, more or less, while waiting for a channel to become ready; if zero, block indefinitely; must not be negative
timeout
)

Implements abstract java.nio.channels.Selector.select.

Selects a set of keys whose corresponding channels are ready for I/O operations.

public int
select()

Implements abstract java.nio.channels.Selector.select.

Selects a set of keys whose corresponding channels are ready for I/O operations.

private int
select0(int timeout)

public Set<SelectionKey>
selectedKeys()

Implements abstract java.nio.channels.Selector.selectedKeys.

Returns this selector's selected-key set.

public int
selectNow()

Implements abstract java.nio.channels.Selector.selectNow.

Selects a set of keys whose corresponding channels are ready for I/O operations.

private void
setOpsReady(AFSelector.PollFd pfd, int selectId)

private int
public Selector
wakeup()

Implements abstract java.nio.channels.Selector.wakeup.

Causes the first selection operation that has not yet returned to return immediately.

Inherited from java.nio.channels.spi.AbstractSelector:
begincancelledKeysclosederegisterendisOpenprovider

Field Detail

keysRegisteredback to summary
private final Map<AFSelectionKey, Integer> keysRegistered
keysRegisteredKeySetback to summary
private final Set<AFSelectionKey> keysRegisteredKeySet
keysRegisteredPublicback to summary
private final Set<SelectionKey> keysRegisteredPublic
pipeMsgReceiveBufferback to summary
private final ByteBuffer pipeMsgReceiveBuffer
pipeMsgWakeUpback to summary
private final ByteBuffer pipeMsgWakeUp
pollFdback to summary
private AFSelector.PollFd pollFd
selectCountback to summary
private final AtomicInteger selectCount
selectedKeysPublicback to summary
private final Set<SelectionKey> selectedKeysPublic
selectedKeysSetback to summary
private final MapValueSet<SelectionKey, Integer> selectedKeysSet
Annotations
@SuppressWarnings:PMD.LooseCoupling
selectorPipeback to summary
private final AFPipe selectorPipe
selectorPipePollFdback to summary
private final AFSelector.PollFd selectorPipePollFd

Constructor Detail

AFSelectorback to summary
pack-priv AFSelector(AFSelectorProvider<?> provider) throws IOException

Method Detail

consumeAllBytesAfterPollback to summary
private synchronized void consumeAllBytesAfterPoll() throws IOException
deregisterback to summary
private void deregister(AFSelectionKey key)
implCloseSelectorback to summary
protected void implCloseSelector() throws IOException

Implements abstract java.nio.channels.spi.AbstractSelector.implCloseSelector.

Doc from java.nio.channels.spi.AbstractSelector.implCloseSelector.

Closes this selector.

This method is invoked by the close method in order to perform the actual work of closing the selector. This method is only invoked if the selector has not yet been closed, and it is never invoked more than once.

An implementation of this method must arrange for any other thread that is blocked in a selection operation upon this selector to return immediately as if by invoking the wakeup method.

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs while closing the selector
initPollFdback to summary
private AFSelector.PollFd initPollFd(AFSelector.PollFd existingPollFd) throws IOException
Annotations
@SuppressWarnings:resource, PMD.CognitiveComplexity
keysback to summary
public Set<SelectionKey> keys()

Implements abstract java.nio.channels.Selector.keys.

Doc from java.nio.channels.Selector.keys.

Returns this selector's key set.

The key set is not directly modifiable. A key is removed only after it has been cancelled and its channel has been deregistered. Any attempt to modify the key set will cause an UnsupportedOperationException to be thrown.

The set is safe for use by multiple concurrent threads.

Returns:Set<SelectionKey>

This selector's key set

Annotations
@Override
receiveback to summary
private int receive(int maxReceive, int options) throws IOException
Annotations
@SuppressWarnings:PMD.CognitiveComplexity
registerback to summary
protected SelectionKey register(AbstractSelectableChannel ch, int ops, Object att)

Implements abstract java.nio.channels.spi.AbstractSelector.register.

Doc from java.nio.channels.spi.AbstractSelector.register.

Registers the given channel with this selector.

This method is invoked by a channel's register method in order to perform the actual work of registering the channel with this selector.

Parameters
ch:AbstractSelectableChannel

The channel to be registered

ops:int

The initial interest set, which must be valid

att:Object

The initial attachment for the resulting key

Returns:SelectionKey

A new key representing the registration of the given channel with this selector

Annotations
@Override
removeback to summary
pack-priv synchronized void remove(AFSelectionKey key)
selectback to summary
public int select(long timeout) throws IOException

Implements abstract java.nio.channels.Selector.select.

Doc from java.nio.channels.Selector.select.

Selects a set of keys whose corresponding channels are ready for I/O operations.

This method performs a blocking selection operation. It returns only after at least one channel is selected, this selector's wakeup method is invoked, the current thread is interrupted, or the given timeout period expires, whichever comes first.

This method does not offer real-time guarantees: It schedules the timeout as if by invoking the Object#wait(long) method.

Parameters
timeout:long

If positive, block for up to timeout milliseconds, more or less, while waiting for a channel to become ready; if zero, block indefinitely; must not be negative

Returns:int

The number of keys, possibly zero, whose ready-operation sets now indicate readiness for at least one category of operations for which the channel was not previously detected to be ready

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
selectback to summary
public int select() throws IOException

Implements abstract java.nio.channels.Selector.select.

Doc from java.nio.channels.Selector.select.

Selects a set of keys whose corresponding channels are ready for I/O operations.

This method performs a blocking selection operation. It returns only after at least one channel is selected, this selector's wakeup method is invoked, or the current thread is interrupted, whichever comes first.

Returns:int

The number of keys, possibly zero, whose ready-operation sets now indicate readiness for at least one category of operations for which the channel was not previously detected to be ready

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
select0back to summary
private int select0(int timeout) throws IOException
Annotations
@SuppressWarnings:PMD.CognitiveComplexity
selectedKeysback to summary
public Set<SelectionKey> selectedKeys()

Implements abstract java.nio.channels.Selector.selectedKeys.

Doc from java.nio.channels.Selector.selectedKeys.

Returns this selector's selected-key set.

Keys may be removed from, but not directly added to, the selected-key set. Any attempt to add an object to the key set will cause an UnsupportedOperationException to be thrown.

The selected-key set is not thread-safe.

Returns:Set<SelectionKey>

This selector's selected-key set

Annotations
@Override
selectNowback to summary
public int selectNow() throws IOException

Implements abstract java.nio.channels.Selector.selectNow.

Doc from java.nio.channels.Selector.selectNow.

Selects a set of keys whose corresponding channels are ready for I/O operations.

This method performs a non-blocking selection operation. If no channels have become selectable since the previous selection operation then this method immediately returns zero.

Invoking this method clears the effect of any previous invocations of the wakeup method.

Returns:int

The number of keys, possibly zero, whose ready-operation sets now indicate readiness for at least one category of operations for which the channel was not previously detected to be ready

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
setOpsReadyback to summary
private void setOpsReady(AFSelector.PollFd pfd, int selectId)
updateSelectCountback to summary
private int updateSelectCount()
wakeupback to summary
public Selector wakeup()

Implements abstract java.nio.channels.Selector.wakeup.

Doc from java.nio.channels.Selector.wakeup.

Causes the first selection operation that has not yet returned to return immediately.

If another thread is currently blocked in a selection operation then that invocation will return immediately. If no selection operation is currently in progress then the next invocation of a selection operation will return immediately unless selectNow() or selectNow(Consumer) is invoked in the meantime. In any case the value returned by that invocation may be non-zero. Subsequent selection operations will block as usual unless this method is invoked again in the meantime.

Invoking this method more than once between two successive selection operations has the same effect as invoking it just once.

Returns:Selector

This selector

Annotations
@Override
org.newsclub.net.unix back to summary

pack-priv final Class AFSelector.PollFd

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv final FileDescriptor[]
pack-priv final AFSelectionKey[]
pack-priv final int[]
pack-priv final int[]

Constructor Summary

AccessConstructor and Description
pack-priv
PollFd(FileDescriptor pipeSourceFd)

pack-priv
PollFd(FileDescriptor pipeSourceFd, int op)

pack-priv
PollFd(FileDescriptor[] fds, int[] ops)

pack-priv
PollFd(AFSelectionKey[] keys, FileDescriptor[] fds, int[] ops)

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

fdsback to summary
pack-priv final FileDescriptor[] fds
keysback to summary
pack-priv final AFSelectionKey[] keys
opsback to summary
pack-priv final int[] ops
ropsback to summary
pack-priv final int[] rops

Constructor Detail

PollFdback to summary
pack-priv PollFd(FileDescriptor pipeSourceFd)
PollFdback to summary
pack-priv PollFd(FileDescriptor pipeSourceFd, int op)
PollFdback to summary
pack-priv PollFd(FileDescriptor[] fds, int[] ops)
PollFdback to summary
pack-priv PollFd(AFSelectionKey[] keys, FileDescriptor[] fds, int[] ops)
Annotations
@SuppressWarnings:PMD.ArrayIsStoredDirectly