Methods Summary |
---|
protected final void | begin()Marks the beginning of an I/O operation that might block indefinitely.
This method should be invoked in tandem with the {@link #end end}
method, using a try ... finally block as
shown above, in order to implement interruption for
this selector.
Invoking this method arranges for the selector's {@link
Selector#wakeup wakeup} method to be invoked if a thread's {@link
Thread#interrupt interrupt} method is invoked while the thread is
blocked in an I/O operation upon the selector.
if (interruptor == null) {
interruptor = new Interruptible() {
public void interrupt() {
AbstractSelector.this.wakeup();
}};
}
AbstractInterruptibleChannel.blockedOn(interruptor);
if (Thread.currentThread().isInterrupted())
interruptor.interrupt();
|
void | cancel(java.nio.channels.SelectionKey k)
// package-private
synchronized (cancelledKeys) {
cancelledKeys.add(k);
}
|
protected final java.util.Set | cancelledKeys()Retrieves this selector's cancelled-key set.
This set should only be used while synchronized upon it.
return cancelledKeys;
|
public final void | close()Closes this selector.
If the selector has already been closed then this method returns
immediately. Otherwise it marks the selector as closed and then invokes
the {@link #implCloseSelector implCloseSelector} method in order to
complete the close operation.
boolean open = selectorOpen.getAndSet(false);
if (!open)
return;
implCloseSelector();
|
protected final void | deregister(java.nio.channels.spi.AbstractSelectionKey key)Removes the given key from its channel's key set.
This method must be invoked by the selector for each channel that it
deregisters.
((AbstractSelectableChannel)key.channel()).removeKey(key);
|
protected final void | end()Marks the end of an I/O operation that might block indefinitely.
This method should be invoked in tandem with the {@link #end end}
method, using a try ... finally block as
shown above, in order to implement interruption for
this selector.
AbstractInterruptibleChannel.blockedOn(null);
|
protected abstract void | implCloseSelector()Closes this selector.
This method is invoked by the {@link #close 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 {@link
java.nio.channels.Selector#wakeup wakeup} method.
|
public final boolean | isOpen()
return selectorOpen.get();
|
public final java.nio.channels.spi.SelectorProvider | provider()Returns the provider that created this channel.
return provider;
|
protected abstract java.nio.channels.SelectionKey | register(java.nio.channels.spi.AbstractSelectableChannel ch, int ops, java.lang.Object att)Registers the given channel with this selector.
This method is invoked by a channel's {@link
AbstractSelectableChannel#register register} method in order to perform
the actual work of registering the channel with this selector.
|