AbstractSelectionKey
abstract class AbstractSelectionKey : SelectionKey
Base implementation class for selection keys.
This class tracks the validity of the key and implements cancellation.
Summary
Inherited constants |
From class SelectionKey
Int |
OP_ACCEPT
Operation-set bit for socket-accept operations.
Suppose that a selection key's interest set contains OP_ACCEPT at the start of a selection operation. If the selector detects that the corresponding server-socket channel is ready to accept another connection, or has an error pending, then it will add OP_ACCEPT to the key's ready set.
|
Int |
OP_CONNECT
Operation-set bit for socket-connect operations.
Suppose that a selection key's interest set contains OP_CONNECT at the start of a selection operation. If the selector detects that the corresponding socket channel is ready to complete its connection sequence, or has an error pending, then it will add OP_CONNECT to the key's ready set.
|
Int |
OP_READ
Operation-set bit for read operations.
Suppose that a selection key's interest set contains OP_READ at the start of a selection operation. If the selector detects that the corresponding channel is ready for reading, has reached end-of-stream, has been remotely shut down for further reading, or has an error pending, then it will add OP_READ to the key's ready-operation set.
|
Int |
OP_WRITE
Operation-set bit for write operations.
Suppose that a selection key's interest set contains OP_WRITE at the start of a selection operation. If the selector detects that the corresponding channel is ready for writing, has been remotely shut down for further writing, or has an error pending, then it will add OP_WRITE to the key's ready set.
|
|
Protected constructors |
Initializes a new instance of this class.
|
Inherited functions |
From class SelectionKey
Any! |
attach(ob: Any!)
Attaches the given object to this key.
An attached object may later be retrieved via the attachment method. Only one object may be attached at a time; invoking this method causes any previous attachment to be discarded. The current attachment may be discarded by attaching null .
|
Any! |
attachment()
Retrieves the current attachment.
|
SelectableChannel! |
channel()
Returns the channel for which this key was created. This method will continue to return the channel even after the key is cancelled.
|
Int |
interestOps()
Retrieves this key's interest set.
It is guaranteed that the returned set will only contain operation bits that are valid for this key's channel.
|
SelectionKey! |
interestOps(ops: Int)
Sets this key's interest set to the given value.
This method may be invoked at any time. If this method is invoked while a selection operation is in progress then it has no effect upon that operation; the change to the key's interest set will be seen by the next selection operation.
|
Int |
interestOpsAnd(ops: Int)
Atomically sets this key's interest set to the bitwise intersection ("and") of the existing interest set and the given value. This method is guaranteed to be atomic with respect to other concurrent calls to this method or to interestOpsOr(int) .
This method may be invoked at any time. If this method is invoked while a selection operation is in progress then it has no effect upon that operation; the change to the key's interest set will be seen by the next selection operation.
|
Int |
interestOpsOr(ops: Int)
Atomically sets this key's interest set to the bitwise union ("or") of the existing interest set and the given value. This method is guaranteed to be atomic with respect to other concurrent calls to this method or to interestOpsAnd(int) .
This method may be invoked at any time. If this method is invoked while a selection operation is in progress then it has no effect upon that operation; the change to the key's interest set will be seen by the next selection operation.
|
Boolean |
isAcceptable()
Tests whether this key's channel is ready to accept a new socket connection.
An invocation of this method of the form k.isAcceptable() behaves in exactly the same way as the expression
<code>k.readyOps() & OP_ACCEPT != 0
</code>
If this key's channel does not support socket-accept operations then this method always returns false .
|
Boolean |
isConnectable()
Tests whether this key's channel has either finished, or failed to finish, its socket-connection operation.
An invocation of this method of the form k.isConnectable() behaves in exactly the same way as the expression
<code>k.readyOps() & OP_CONNECT != 0
</code>
If this key's channel does not support socket-connect operations then this method always returns false .
|
Boolean |
isReadable()
Tests whether this key's channel is ready for reading.
An invocation of this method of the form k.isReadable() behaves in exactly the same way as the expression
<code>k.readyOps() & OP_READ != 0
</code>
If this key's channel does not support read operations then this method always returns false .
|
Boolean |
isWritable()
Tests whether this key's channel is ready for writing.
An invocation of this method of the form k.isWritable() behaves in exactly the same way as the expression
<code>k.readyOps() & OP_WRITE != 0
</code>
If this key's channel does not support write operations then this method always returns false .
|
Int |
readyOps()
Retrieves this key's ready-operation set.
It is guaranteed that the returned set will only contain operation bits that are valid for this key's channel.
|
Selector! |
selector()
Returns the selector for which this key was created. This method will continue to return the selector even after the key is cancelled.
|
|
Protected constructors
AbstractSelectionKey
protected AbstractSelectionKey()
Initializes a new instance of this class.
Public methods
cancel
fun cancel(): Unit
Cancels this key.
If this key has not yet been cancelled then it is added to its selector's cancelled-key set while synchronized on that set.
isValid
fun isValid(): Boolean
Return |
Boolean |
true if, and only if, this key is valid |