Class SelectableImpl
- java.lang.Object
-
- org.apache.qpid.proton.reactor.impl.SelectableImpl
-
- All Implemented Interfaces:
Extendable
,ReactorChild
,Selectable
public class SelectableImpl extends java.lang.Object implements Selectable
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.qpid.proton.reactor.Selectable
Selectable.Callback
-
-
Constructor Summary
Constructors Constructor Description SelectableImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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 underlyingSelectableChannel
is ready for a read operation.void
release()
Notify the selectable that it has been released.void
setChannel(java.nio.channels.SelectableChannel channel)
Associates aSelectableChannel
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 bySelectable.getDeadline()
.protected void
setReactor(Reactor reactor)
void
setReading(boolean reading)
Sets the value that will be returned bySelectable.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 bySelectable.isWriting()
.void
terminate()
Terminates the selectable.void
terminated()
void
writeable()
Notify the selectable that the underlyingSelectableChannel
is ready for a write operation.
-
-
-
Method Detail
-
isReading
public boolean isReading()
- Specified by:
isReading
in interfaceSelectable
- Returns:
true
if the selectable is interested in receiving notification (via theSelectable.readable()
method that indicate that the associatedSelectableChannel
has data ready to be read from it.
-
isWriting
public boolean isWriting()
- Specified by:
isWriting
in interfaceSelectable
- Returns:
true
if the selectable is interested in receiving notifications (via theSelectable.writeable()
method that indicate that the associatedSelectableChannel
is ready to be written to.
-
getDeadline
public long getDeadline()
- Specified by:
getDeadline
in interfaceSelectable
- Returns:
- a deadline after which this selectable can expect to receive
a notification (via the
Selectable.expired()
method that indicates that the deadline has past. The deadline is expressed in the same format asSystem.currentTimeMillis()
. Returning a deadline of zero (or a negative number) indicates that the selectable does not wish to be notified of expiry.
-
setReading
public void setReading(boolean reading)
Description copied from interface:Selectable
Sets the value that will be returned bySelectable.isReading()
.- Specified by:
setReading
in interfaceSelectable
-
setWriting
public void setWriting(boolean writing)
Description copied from interface:Selectable
Sets the value that will be returned bySelectable.isWriting()
.- Specified by:
setWriting
in interfaceSelectable
-
setDeadline
public void setDeadline(long deadline)
Description copied from interface:Selectable
Sets the value that will be returned bySelectable.getDeadline()
.- Specified by:
setDeadline
in interfaceSelectable
-
onReadable
public void onReadable(Selectable.Callback runnable)
Description copied from interface:Selectable
Registers a callback that will be run when the selectable becomes ready for reading.- Specified by:
onReadable
in interfaceSelectable
- Parameters:
runnable
- the callback to register. Any previously registered callback will be replaced.
-
onWritable
public void onWritable(Selectable.Callback runnable)
Description copied from interface:Selectable
Registers a callback that will be run when the selectable becomes ready for writing.- Specified by:
onWritable
in interfaceSelectable
- Parameters:
runnable
- the callback to register. Any previously registered callback will be replaced.
-
onExpired
public void onExpired(Selectable.Callback runnable)
Description copied from interface:Selectable
Registers a callback that will be run when the selectable expires.- Specified by:
onExpired
in interfaceSelectable
- Parameters:
runnable
- the callback to register. Any previously registered callback will be replaced.
-
onError
public void onError(Selectable.Callback runnable)
Description copied from interface:Selectable
Registers a callback that will be run when the selectable is notified of an error.- Specified by:
onError
in interfaceSelectable
- Parameters:
runnable
- the callback to register. Any previously registered callback will be replaced.
-
onRelease
public void onRelease(Selectable.Callback runnable)
Description copied from interface:Selectable
Registers a callback that will be run when the selectable is notified that it has been released.- Specified by:
onRelease
in interfaceSelectable
- Parameters:
runnable
- the callback to register. Any previously registered callback will be replaced.
-
onFree
public void onFree(Selectable.Callback runnable)
Description copied from interface:Selectable
Registers a callback that will be run when the selectable is notified that it has been free'd.- Specified by:
onFree
in interfaceSelectable
- Parameters:
runnable
- the callback to register. Any previously registered callback will be replaced.
-
readable
public void readable()
Description copied from interface:Selectable
Notify the selectable that the underlyingSelectableChannel
is ready for a read operation.- Specified by:
readable
in interfaceSelectable
-
writeable
public void writeable()
Description copied from interface:Selectable
Notify the selectable that the underlyingSelectableChannel
is ready for a write operation.- Specified by:
writeable
in interfaceSelectable
-
expired
public void expired()
Description copied from interface:Selectable
Notify the selectable that it has expired.- Specified by:
expired
in interfaceSelectable
-
error
public void error()
Description copied from interface:Selectable
Notify the selectable that an error has occurred.- Specified by:
error
in interfaceSelectable
-
release
public void release()
Description copied from interface:Selectable
Notify the selectable that it has been released.- Specified by:
release
in interfaceSelectable
-
free
public void free()
Description copied from interface:Selectable
Notify the selectable that it has been free'd.- Specified by:
free
in interfaceReactorChild
- Specified by:
free
in interfaceSelectable
-
setChannel
public void setChannel(java.nio.channels.SelectableChannel channel)
Description copied from interface:Selectable
Associates aSelectableChannel
with this selector.- Specified by:
setChannel
in interfaceSelectable
-
getChannel
public java.nio.channels.SelectableChannel getChannel()
- Specified by:
getChannel
in interfaceSelectable
- Returns:
- the
SelectableChannel
associated with this selector.
-
isRegistered
public boolean isRegistered()
Description copied from interface:Selectable
Check if a selectable is registered. This can be used for tracking whether a given selectable has been registerd with an external event loop.Note: the reactor code, currently, does not use this flag.
- Specified by:
isRegistered
in interfaceSelectable
- Returns:
true
if the selectable is registered.
-
setRegistered
public void setRegistered(boolean registered)
Description copied from interface:Selectable
Set the registered flag for a selectable.Note: the reactor code, currently, does not use this flag.
- Specified by:
setRegistered
in interfaceSelectable
- Parameters:
registered
- the value returned bySelectable.isRegistered()
-
setCollector
public void setCollector(Collector collector)
Description copied from interface:Selectable
Configure a selectable with a set of callbacks that emit readable, writable, and expired events into the supplied collector.- Specified by:
setCollector
in interfaceSelectable
-
getReactor
public Reactor getReactor()
- Specified by:
getReactor
in interfaceSelectable
- Returns:
- the reactor to which this selectable is a child.
-
terminate
public void terminate()
Description copied from interface:Selectable
Terminates the selectable. Once a selectable reaches a terminal state it will never be interested in events of any kind.- Specified by:
terminate
in interfaceSelectable
-
isTerminal
public boolean isTerminal()
- Specified by:
isTerminal
in interfaceSelectable
- Returns:
true
if the selectable has reached a terminal state.
-
getTransport
protected Transport getTransport()
-
setTransport
protected void setTransport(Transport transport)
-
setReactor
protected void setReactor(Reactor reactor)
-
attachments
public Record attachments()
- Specified by:
attachments
in interfaceExtendable
-
isTerminated
public boolean isTerminated()
-
terminated
public void terminated()
-
-