Class TemporarySelectorStateOpen
- All Implemented Interfaces:
TemporarySelectorState
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance of TemporarySelectorStateOpen -
Method Summary
Modifier and TypeMethodDescriptioncancelKeyAndFlushSelector
(Selector theSelector, SelectionKey theSelectionKey) Requests that the registration of a SelectableChannel with theSelector, theSelectionKey be cancelled and flushed from theSelector.Closes theSelector.registerChannel
(Selector theSelector, SelectableChannel theSelectableChannel, int theOps) Registers theSelectableChannel with theSelector, setting theSelection to the key returned by the registeration.removeSelectedKey
(Selector theSelector, SelectionKey theSelectionKey) Remove theSelectionKey from the theSelector's selected key set.int
Selects a set of keys whose corresponding SelectableChannel is ready for I/O operations.
-
Field Details
-
wrapper
-
-
Constructor Details
-
TemporarySelectorStateOpen
public TemporarySelectorStateOpen()Creates a new instance of TemporarySelectorStateOpen
-
-
Method Details
-
select
Description copied from interface:TemporarySelectorState
Selects a set of keys whose corresponding SelectableChannel is ready for I/O operations.This 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.- Specified by:
select
in interfaceTemporarySelectorState
- Parameters:
theSelector
- The Selector to usetheTimeout
- 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 value- Returns:
- The number of keys, possibly zero, whose ready-operation sets was updated.
- Throws:
IOException
- If an I/O error occurs
-
registerChannel
public SelectionKey registerChannel(Selector theSelector, SelectableChannel theSelectableChannel, int theOps) throws IOException Description copied from interface:TemporarySelectorState
Registers theSelectableChannel with theSelector, setting theSelection to the key returned by the registeration.- Specified by:
registerChannel
in interfaceTemporarySelectorState
- Parameters:
theSelector
- The selector with which this channel is to be registeredtheSelectableChannel
- The SelectableChannel to register theSelector with.theOps
- The interest set for the resulting key- Returns:
- A key representing the registration of theSelectableChannel with theSelector.
- Throws:
IOException
-
cancelKeyAndFlushSelector
public TemporarySelectorState cancelKeyAndFlushSelector(Selector theSelector, SelectionKey theSelectionKey) throws IOException Description copied from interface:TemporarySelectorState
Requests that the registration of a SelectableChannel with theSelector, theSelectionKey be cancelled and flushed from theSelector. Upon return theSelectionKey will be invalid and will have been flushed from theSelector's key sets.If 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.
- Specified by:
cancelKeyAndFlushSelector
in interfaceTemporarySelectorState
- Parameters:
theSelector
- The selector with which this channel is to be registeredtheSelectionKey
- A key representing the registration of theSelectableChannel with theSelector- Returns:
- TemporarySelectorState, the state of the TemporarySelector after invoking this method.
- Throws:
IOException
- if an error occurred
-
close
Description copied from interface:TemporarySelectorState
Closes theSelector.If 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.
- Specified by:
close
in interfaceTemporarySelectorState
- Parameters:
theSelector
- The selector with which this channel is to be registered- Returns:
- TemporarySelectorState, the state of the TemporarySelector after invoking this method.
- Throws:
IOException
- If an I/O error occurs
-
removeSelectedKey
public TemporarySelectorState removeSelectedKey(Selector theSelector, SelectionKey theSelectionKey) throws IOException Description copied from interface:TemporarySelectorState
Remove theSelectionKey from the theSelector's selected key set.- Specified by:
removeSelectedKey
in interfaceTemporarySelectorState
- Parameters:
theSelector
- 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.- Returns:
- TemporarySelectorState, the state of the TemporarySelector after invoking this method.
- Throws:
IOException
- If this selector is closed
-