|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.nio.channels.spi.AbstractInterruptibleChannel
java.nio.channels.SelectableChannel
java.nio.channels.spi.AbstractSelectableChannel
public abstract class AbstractSelectableChannel
Abstract class for selectable channels.
In this class, there are methods about registering/deregistering a channel, about channel closing. It realize the multi-thread safe.
| Field Summary | |
|---|---|
(package private) boolean |
isBlocking
|
| Fields inherited from class java.nio.channels.spi.AbstractInterruptibleChannel |
|---|
interrupted, setInterruptAction |
| Constructor Summary | |
|---|---|
protected |
AbstractSelectableChannel(SelectorProvider selectorProvider)
Constructor for this class. |
| Method Summary | |
|---|---|
Object |
blockingLock()
Gets the blocking lock which synchronizes the configureBlocking and register methods. |
SelectableChannel |
configureBlocking(boolean blockingMode)
Set the blocking mode of this channel. |
(package private) void |
deregister(SelectionKey k)
|
protected void |
implCloseChannel()
Implement the closing function. |
protected abstract void |
implCloseSelectableChannel()
Implement the closing function of the SelectableChannel. |
protected abstract void |
implConfigureBlocking(boolean blockingMode)
Implement the setting of blocking mode. |
boolean |
isBlocking()
Returns if channel is in blocking mode. |
boolean |
isRegistered()
Returns if channel is registered. |
SelectionKey |
keyFor(Selector selector)
Gets the selection key for the channel with the given selector. |
SelectorProvider |
provider()
Answer the SelectorProvider of this channel. |
SelectionKey |
register(Selector selector,
int interestSet,
Object attachment)
Realize the register function. |
| Methods inherited from class java.nio.channels.SelectableChannel |
|---|
register, validOps |
| Methods inherited from class java.nio.channels.spi.AbstractInterruptibleChannel |
|---|
begin, close, end, isOpen |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface java.nio.channels.Channel |
|---|
close, isOpen |
| Field Detail |
|---|
boolean isBlocking
| Constructor Detail |
|---|
protected AbstractSelectableChannel(SelectorProvider selectorProvider)
selectorProvider - A instance of SelectorProvider| Method Detail |
|---|
public final SelectorProvider provider()
provider in class SelectableChannelSelectableChannel.provider()public final boolean isRegistered()
SelectableChannel
isRegistered in class SelectableChannelSelectableChannel.isRegistered()public final SelectionKey keyFor(Selector selector)
SelectableChannel
keyFor in class SelectableChannelselector - the selector with which this channel may register
SelectableChannel.keyFor(java.nio.channels.Selector)
public final SelectionKey register(Selector selector,
int interestSet,
Object attachment)
throws ClosedChannelException
It registers current channel to the selector, then answer the selection
key. The channel must be open and the interest op set must be valid. If
the current channel is already registered to the selector, the method
only set the new interest op set; otherwise it will call the
register in selector, and add the relative
key to the key set of the current channel.
register in class SelectableChannelselector - the selector with which this channel shall be registeredinterestSet - the interesting operationattachment - The attached object, which can be null
ClosedChannelException - if the channel is closedSelectableChannel.register(java.nio.channels.Selector,
int, java.lang.Object)
protected final void implCloseChannel()
throws IOException
implCloseChannel in class AbstractInterruptibleChannelIOException - if a problem occurs closing the channel.AbstractInterruptibleChannel.implCloseChannel()
protected abstract void implCloseSelectableChannel()
throws IOException
IOException - If some I/O exception occurred.public final boolean isBlocking()
SelectableChannel
isBlocking in class SelectableChannelSelectableChannel.isBlocking()public final Object blockingLock()
SelectableChannel
blockingLock in class SelectableChannelSelectableChannel.blockingLock()
public final SelectableChannel configureBlocking(boolean blockingMode)
throws IOException
configureBlocking in class SelectableChannelblockingMode - true for blocking mode; false
for non-blocking mode.
ClosedChannelException - If this channel has been closed
IOException - if I/O error occursSelectableChannel.configureBlocking(boolean)
protected abstract void implConfigureBlocking(boolean blockingMode)
throws IOException
blockingMode - true for blocking mode; false
for non-blocking mode.
IOException - If some I/O exception occurred.void deregister(SelectionKey k)
|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||