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 Recordattachments()voiderror()Notify the selectable that an error has occurred.voidexpired()Notify the selectable that it has expired.voidfree()Notify the selectable that it has been free'd.java.nio.channels.SelectableChannelgetChannel()longgetDeadline()ReactorgetReactor()protected TransportgetTransport()booleanisReading()booleanisRegistered()Check if a selectable is registered.booleanisTerminal()booleanisTerminated()booleanisWriting()voidonError(Selectable.Callback runnable)Registers a callback that will be run when the selectable is notified of an error.voidonExpired(Selectable.Callback runnable)Registers a callback that will be run when the selectable expires.voidonFree(Selectable.Callback runnable)Registers a callback that will be run when the selectable is notified that it has been free'd.voidonReadable(Selectable.Callback runnable)Registers a callback that will be run when the selectable becomes ready for reading.voidonRelease(Selectable.Callback runnable)Registers a callback that will be run when the selectable is notified that it has been released.voidonWritable(Selectable.Callback runnable)Registers a callback that will be run when the selectable becomes ready for writing.voidreadable()Notify the selectable that the underlyingSelectableChannelis ready for a read operation.voidrelease()Notify the selectable that it has been released.voidsetChannel(java.nio.channels.SelectableChannel channel)Associates aSelectableChannelwith this selector.voidsetCollector(Collector collector)Configure a selectable with a set of callbacks that emit readable, writable, and expired events into the supplied collector.voidsetDeadline(long deadline)Sets the value that will be returned bySelectable.getDeadline().protected voidsetReactor(Reactor reactor)voidsetReading(boolean reading)Sets the value that will be returned bySelectable.isReading().voidsetRegistered(boolean registered)Set the registered flag for a selectable.protected voidsetTransport(Transport transport)voidsetWriting(boolean writing)Sets the value that will be returned bySelectable.isWriting().voidterminate()Terminates the selectable.voidterminated()voidwriteable()Notify the selectable that the underlyingSelectableChannelis ready for a write operation.
-
-
-
Method Detail
-
isReading
public boolean isReading()
- Specified by:
isReadingin interfaceSelectable- Returns:
trueif the selectable is interested in receiving notification (via theSelectable.readable()method that indicate that the associatedSelectableChannelhas data ready to be read from it.
-
isWriting
public boolean isWriting()
- Specified by:
isWritingin interfaceSelectable- Returns:
trueif the selectable is interested in receiving notifications (via theSelectable.writeable()method that indicate that the associatedSelectableChannelis ready to be written to.
-
getDeadline
public long getDeadline()
- Specified by:
getDeadlinein 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:SelectableSets the value that will be returned bySelectable.isReading().- Specified by:
setReadingin interfaceSelectable
-
setWriting
public void setWriting(boolean writing)
Description copied from interface:SelectableSets the value that will be returned bySelectable.isWriting().- Specified by:
setWritingin interfaceSelectable
-
setDeadline
public void setDeadline(long deadline)
Description copied from interface:SelectableSets the value that will be returned bySelectable.getDeadline().- Specified by:
setDeadlinein interfaceSelectable
-
onReadable
public void onReadable(Selectable.Callback runnable)
Description copied from interface:SelectableRegisters a callback that will be run when the selectable becomes ready for reading.- Specified by:
onReadablein 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:SelectableRegisters a callback that will be run when the selectable becomes ready for writing.- Specified by:
onWritablein 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:SelectableRegisters a callback that will be run when the selectable expires.- Specified by:
onExpiredin 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:SelectableRegisters a callback that will be run when the selectable is notified of an error.- Specified by:
onErrorin 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:SelectableRegisters a callback that will be run when the selectable is notified that it has been released.- Specified by:
onReleasein 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:SelectableRegisters a callback that will be run when the selectable is notified that it has been free'd.- Specified by:
onFreein interfaceSelectable- Parameters:
runnable- the callback to register. Any previously registered callback will be replaced.
-
readable
public void readable()
Description copied from interface:SelectableNotify the selectable that the underlyingSelectableChannelis ready for a read operation.- Specified by:
readablein interfaceSelectable
-
writeable
public void writeable()
Description copied from interface:SelectableNotify the selectable that the underlyingSelectableChannelis ready for a write operation.- Specified by:
writeablein interfaceSelectable
-
expired
public void expired()
Description copied from interface:SelectableNotify the selectable that it has expired.- Specified by:
expiredin interfaceSelectable
-
error
public void error()
Description copied from interface:SelectableNotify the selectable that an error has occurred.- Specified by:
errorin interfaceSelectable
-
release
public void release()
Description copied from interface:SelectableNotify the selectable that it has been released.- Specified by:
releasein interfaceSelectable
-
free
public void free()
Description copied from interface:SelectableNotify the selectable that it has been free'd.- Specified by:
freein interfaceReactorChild- Specified by:
freein interfaceSelectable
-
setChannel
public void setChannel(java.nio.channels.SelectableChannel channel)
Description copied from interface:SelectableAssociates aSelectableChannelwith this selector.- Specified by:
setChannelin interfaceSelectable
-
getChannel
public java.nio.channels.SelectableChannel getChannel()
- Specified by:
getChannelin interfaceSelectable- Returns:
- the
SelectableChannelassociated with this selector.
-
isRegistered
public boolean isRegistered()
Description copied from interface:SelectableCheck 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:
isRegisteredin interfaceSelectable- Returns:
trueif the selectable is registered.
-
setRegistered
public void setRegistered(boolean registered)
Description copied from interface:SelectableSet the registered flag for a selectable.Note: the reactor code, currently, does not use this flag.
- Specified by:
setRegisteredin interfaceSelectable- Parameters:
registered- the value returned bySelectable.isRegistered()
-
setCollector
public void setCollector(Collector collector)
Description copied from interface:SelectableConfigure a selectable with a set of callbacks that emit readable, writable, and expired events into the supplied collector.- Specified by:
setCollectorin interfaceSelectable
-
getReactor
public Reactor getReactor()
- Specified by:
getReactorin interfaceSelectable- Returns:
- the reactor to which this selectable is a child.
-
terminate
public void terminate()
Description copied from interface:SelectableTerminates the selectable. Once a selectable reaches a terminal state it will never be interested in events of any kind.- Specified by:
terminatein interfaceSelectable
-
isTerminal
public boolean isTerminal()
- Specified by:
isTerminalin interfaceSelectable- Returns:
trueif 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:
attachmentsin interfaceExtendable
-
isTerminated
public boolean isTerminated()
-
terminated
public void terminated()
-
-