public class TemporarySelectorStateOpen extends Object implements TemporarySelectorState
| Constructor and Description |
|---|
TemporarySelectorStateOpen()
Creates a new instance of TemporarySelectorStateOpen
|
| Modifier and Type | Method and Description |
|---|---|
TemporarySelectorState |
cancelKeyAndFlushSelector(Selector theSelector,
SelectionKey theSelectionKey)
Requests that the registration of a SelectableChannel with theSelector,
theSelectionKey be cancelled and flushed from theSelector.
|
TemporarySelectorState |
close(Selector theSelector)
Closes theSelector.
|
SelectionKey |
registerChannel(Selector theSelector,
SelectableChannel theSelectableChannel,
int theOps)
Registers theSelectableChannel with theSelector, setting theSelection to
the key returned by the registeration.
|
TemporarySelectorState |
removeSelectedKey(Selector theSelector,
SelectionKey theSelectionKey)
Remove theSelectionKey from the theSelector's selected key set.
|
int |
select(Selector theSelector,
long theTimeout)
Selects a set of keys whose corresponding SelectableChannel is ready for
I/O operations.
|
public TemporarySelectorStateOpen()
public int select(Selector theSelector, long theTimeout) throws IOException
TemporarySelectorStateThis method performs a blocking selection operation on theSelector. It returns only after the SelectableChannel is selected, theSelector'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
theTimeout as if by invoking the Object.wait(long) method.
select in interface TemporarySelectorStatetheTimeout - If positive, block for up to theTimeout
milliseconds, more or less, while waiting for a
SelectableChannel to become ready; must be greater
than 0 in valueIOException - If an I/O error occurspublic SelectionKey registerChannel(Selector theSelector, SelectableChannel theSelectableChannel, int theOps) throws IOException
TemporarySelectorStateregisterChannel in interface TemporarySelectorStatetheSelector - The selector with which this channel is to be registeredtheSelectableChannel - The SelectableChannel to register theSelector with.theOps - The interest set for the resulting keyIOExceptionpublic TemporarySelectorState cancelKeyAndFlushSelector(Selector theSelector, SelectionKey theSelectionKey) throws IOException
TemporarySelectorStateIf theSelectionKey has already been cancelled and it has been flushed from theSelector, then invoking this method has no effect. Once theSelectionKey is cancelled and flushed, theSelectionKey remains forever invalid.
This method may be invoked at any time. It synchronizes on the theSelector's cancelled-key set, and therefore may block briefly if invoked concurrently with a cancellation or selection operation involving the same selector.
cancelKeyAndFlushSelector in interface TemporarySelectorStatetheSelector - The selector with which this channel is to be registeredtheSelectionKey - A key representing the registration of theSelectableChannel with
theSelectorIOExceptionpublic TemporarySelectorState close(Selector theSelector) throws IOException
TemporarySelectorStateIf a thread is currently blocked in one of theSelector's selection methods then it is interrupted as if by invoking theSelector's wakeup method.
Any uncancelled keys still associated with theSelector are invalidated, their SelectableChannels are deregistered, and any other resources associated with this selector are released.
If theSelector is already closed then invoking this method has no effect.
After theSelector is closed, any further attempt to use it, except by invoking this method, will cause a ClosedSelectorException to be thrown.
close in interface TemporarySelectorStatetheSelector - The selector with which this channel is to be registeredIOException - If an I/O error occurspublic TemporarySelectorState removeSelectedKey(Selector theSelector, SelectionKey theSelectionKey) throws IOException
TemporarySelectorStateremoveSelectedKey in interface TemporarySelectorStatetheSelector - The selector whose selected key set should have theSelectionKey
removed.theSelectionKey - A key representing the registration of theSelectableChannel with
theSelector and the key should be removed key removed from the
selected key set.IOException - If this selector is closedCopyright © 2017–2019 Eclipse Foundation. All rights reserved.