SelectableChannel class abstract
A channel that can be multiplexed via a {@link Selector}.
In order to be used with a selector, an instance of this class must first be registered via the {@link #register(Selector,int,Object) register} method. This method returns a new {@link SelectionKey} object that represents the channel's registration with the selector.
Once registered with a selector, a channel remains registered until it is deregistered. This involves deallocating whatever resources were allocated to the channel by the selector.
A channel cannot be deregistered directly; instead, the key representing its registration must be cancelled. Cancelling a key requests that the channel be deregistered during the selector's next selection operation. A key may be cancelled explicitly by invoking its {@link SelectionKey#cancel() cancel} method. All of a channel's keys are cancelled implicitly when the channel is closed, whether by invoking its {@link Channel#close close} method or by interrupting a thread blocked in an I/O operation upon the channel.
If the selector itself is closed then the channel will be deregistered, and the key representing its registration will be invalidated, without further delay.
A channel may be registered at most once with any particular selector.
Whether or not a channel is registered with one or more selectors may be determined by invoking the {@link #isRegistered isRegistered} method.
Selectable channels are safe for use by multiple concurrent threads.
Blocking mode
A selectable channel is either in blocking mode or in non-blocking mode. In blocking mode, every I/O operation invoked upon the channel will block until it completes. In non-blocking mode an I/O operation will never block and may transfer fewer bytes than were requested or possibly no bytes at all. The blocking mode of a selectable channel may be determined by invoking its {@link #isBlocking isBlocking} method.
Newly-created selectable channels are always in blocking mode. Non-blocking mode is most useful in conjunction with selector-based multiplexing. A channel must be placed into non-blocking mode before being registered with a selector, and may not be returned to blocking mode until it has been deregistered.
- Inheritance
-
- Object
- AbstractInterruptibleChannel
- SelectableChannel
- Implementers
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- isBlocking → bool
-
Tells whether or not every I/O operation on this channel will block
until it completes. A newly-created channel is always in blocking mode.
no setter
- isClosed → bool
-
Tells whether or not this channel is open.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
close(
) → Future< void> -
Closes this stream and releases any system resources associated
with it. If the stream is already closed then invoking this
method has no effect.
inherited
-
configureBlocking(
bool block) → SelectableChannel? - Adjusts this channel's blocking mode.
-
implCloseChannel(
) → Future< void> -
Closes this channel.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited