public class SelectableImpl extends java.lang.Object implements Selectable
Selectable.Callback
Constructor and Description |
---|
SelectableImpl() |
Modifier and Type | Method and Description |
---|---|
Record |
attachments() |
void |
error()
Notify the selectable that an error has occurred.
|
void |
expired()
Notify the selectable that it has expired.
|
void |
free()
Notify the selectable that it has been free'd.
|
java.nio.channels.SelectableChannel |
getChannel() |
long |
getDeadline() |
Reactor |
getReactor() |
protected Transport |
getTransport() |
boolean |
isReading() |
boolean |
isRegistered()
Check if a selectable is registered.
|
boolean |
isTerminal() |
boolean |
isTerminated() |
boolean |
isWriting() |
void |
onError(Selectable.Callback runnable)
Registers a callback that will be run when the selectable is notified of
an error.
|
void |
onExpired(Selectable.Callback runnable)
Registers a callback that will be run when the selectable expires.
|
void |
onFree(Selectable.Callback runnable)
Registers a callback that will be run when the selectable is notified
that it has been free'd.
|
void |
onReadable(Selectable.Callback runnable)
Registers a callback that will be run when the selectable becomes ready
for reading.
|
void |
onRelease(Selectable.Callback runnable)
Registers a callback that will be run when the selectable is notified
that it has been released.
|
void |
onWritable(Selectable.Callback runnable)
Registers a callback that will be run when the selectable becomes ready
for writing.
|
void |
readable()
Notify the selectable that the underlying
SelectableChannel is
ready for a read operation. |
void |
release()
Notify the selectable that it has been released.
|
void |
setChannel(java.nio.channels.SelectableChannel channel)
Associates a
SelectableChannel with this selector. |
void |
setCollector(Collector collector)
Configure a selectable with a set of callbacks that emit readable,
writable, and expired events into the supplied collector.
|
void |
setDeadline(long deadline)
Sets the value that will be returned by
Selectable.getDeadline() . |
protected void |
setReactor(Reactor reactor) |
void |
setReading(boolean reading)
Sets the value that will be returned by
Selectable.isReading() . |
void |
setRegistered(boolean registered)
Set the registered flag for a selectable.
|
protected void |
setTransport(Transport transport) |
void |
setWriting(boolean writing)
Sets the value that will be returned by
Selectable.isWriting() . |
void |
terminate()
Terminates the selectable.
|
void |
terminated() |
void |
writeable()
Notify the selectable that the underlying
SelectableChannel is
ready for a write operation. |
public boolean isReading()
isReading
in interface Selectable
true
if the selectable is interested in receiving
notification (via the Selectable.readable()
method that indicate
that the associated SelectableChannel
has data ready
to be read from it.public boolean isWriting()
isWriting
in interface Selectable
true
if the selectable is interested in receiving
notifications (via the Selectable.writeable()
method that indicate
that the associated SelectableChannel
is ready to be
written to.public long getDeadline()
getDeadline
in interface Selectable
Selectable.expired()
method that indicates
that the deadline has past. The deadline is expressed in the
same format as System.currentTimeMillis()
. Returning
a deadline of zero (or a negative number) indicates that the
selectable does not wish to be notified of expiry.public void setReading(boolean reading)
Selectable
Selectable.isReading()
.setReading
in interface Selectable
public void setWriting(boolean writing)
Selectable
Selectable.isWriting()
.setWriting
in interface Selectable
public void setDeadline(long deadline)
Selectable
Selectable.getDeadline()
.setDeadline
in interface Selectable
public void onReadable(Selectable.Callback runnable)
Selectable
onReadable
in interface Selectable
runnable
- the callback to register. Any previously registered
callback will be replaced.public void onWritable(Selectable.Callback runnable)
Selectable
onWritable
in interface Selectable
runnable
- the callback to register. Any previously registered
callback will be replaced.public void onExpired(Selectable.Callback runnable)
Selectable
onExpired
in interface Selectable
runnable
- the callback to register. Any previously registered
callback will be replaced.public void onError(Selectable.Callback runnable)
Selectable
onError
in interface Selectable
runnable
- the callback to register. Any previously registered
callback will be replaced.public void onRelease(Selectable.Callback runnable)
Selectable
onRelease
in interface Selectable
runnable
- the callback to register. Any previously registered
callback will be replaced.public void onFree(Selectable.Callback runnable)
Selectable
onFree
in interface Selectable
runnable
- the callback to register. Any previously registered
callback will be replaced.public void readable()
Selectable
SelectableChannel
is
ready for a read operation.readable
in interface Selectable
public void writeable()
Selectable
SelectableChannel
is
ready for a write operation.writeable
in interface Selectable
public void expired()
Selectable
expired
in interface Selectable
public void error()
Selectable
error
in interface Selectable
public void release()
Selectable
release
in interface Selectable
public void free()
Selectable
free
in interface ReactorChild
free
in interface Selectable
public void setChannel(java.nio.channels.SelectableChannel channel)
Selectable
SelectableChannel
with this selector.setChannel
in interface Selectable
public java.nio.channels.SelectableChannel getChannel()
getChannel
in interface Selectable
SelectableChannel
associated with this selector.public boolean isRegistered()
Selectable
Note: the reactor code, currently, does not use this flag.
isRegistered
in interface Selectable
true
if the selectable is registered.public void setRegistered(boolean registered)
Selectable
Note: the reactor code, currently, does not use this flag.
setRegistered
in interface Selectable
registered
- the value returned by Selectable.isRegistered()
public void setCollector(Collector collector)
Selectable
setCollector
in interface Selectable
public Reactor getReactor()
getReactor
in interface Selectable
public void terminate()
Selectable
terminate
in interface Selectable
public boolean isTerminal()
isTerminal
in interface Selectable
true
if the selectable has reached a terminal state.protected Transport getTransport()
protected void setTransport(Transport transport)
protected void setReactor(Reactor reactor)
public Record attachments()
attachments
in interface Extendable
public boolean isTerminated()
public void terminated()