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 Selectabletrue 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 Selectabletrue 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 SelectableSelectable.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)
SelectableSelectable.isReading().setReading in interface Selectablepublic void setWriting(boolean writing)
SelectableSelectable.isWriting().setWriting in interface Selectablepublic void setDeadline(long deadline)
SelectableSelectable.getDeadline().setDeadline in interface Selectablepublic void onReadable(Selectable.Callback runnable)
SelectableonReadable in interface Selectablerunnable - the callback to register. Any previously registered
callback will be replaced.public void onWritable(Selectable.Callback runnable)
SelectableonWritable in interface Selectablerunnable - the callback to register. Any previously registered
callback will be replaced.public void onExpired(Selectable.Callback runnable)
SelectableonExpired in interface Selectablerunnable - the callback to register. Any previously registered
callback will be replaced.public void onError(Selectable.Callback runnable)
SelectableonError in interface Selectablerunnable - the callback to register. Any previously registered
callback will be replaced.public void onRelease(Selectable.Callback runnable)
SelectableonRelease in interface Selectablerunnable - the callback to register. Any previously registered
callback will be replaced.public void onFree(Selectable.Callback runnable)
SelectableonFree in interface Selectablerunnable - the callback to register. Any previously registered
callback will be replaced.public void readable()
SelectableSelectableChannel is
ready for a read operation.readable in interface Selectablepublic void writeable()
SelectableSelectableChannel is
ready for a write operation.writeable in interface Selectablepublic void expired()
Selectableexpired in interface Selectablepublic void error()
Selectableerror in interface Selectablepublic void release()
Selectablerelease in interface Selectablepublic void free()
Selectablefree in interface ReactorChildfree in interface Selectablepublic void setChannel(java.nio.channels.SelectableChannel channel)
SelectableSelectableChannel with this selector.setChannel in interface Selectablepublic java.nio.channels.SelectableChannel getChannel()
getChannel in interface SelectableSelectableChannel associated with this selector.public boolean isRegistered()
SelectableNote: the reactor code, currently, does not use this flag.
isRegistered in interface Selectabletrueif the selectable is registered.public void setRegistered(boolean registered)
SelectableNote: the reactor code, currently, does not use this flag.
setRegistered in interface Selectableregistered - the value returned by Selectable.isRegistered()public void setCollector(Collector collector)
SelectablesetCollector in interface Selectablepublic Reactor getReactor()
getReactor in interface Selectablepublic void terminate()
Selectableterminate in interface Selectablepublic boolean isTerminal()
isTerminal in interface Selectabletrue 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 Extendablepublic boolean isTerminated()
public void terminated()