public interface DisconnectAwareConnection<T> extends Connection<T>
DisconnectAwareConnection is a connection capable of executing an action when
the other side of connection disconnects before the stop method is called on this connection.
Implementations must guarantee that the disconnect action completes before null is returned from
the Receive.receive() method. Furthermore, if a disconnect action has not yet been set the receive() method
MUST NOT return null until a disconnection action is set and executed. This means that if #labelonDisconnect(Runnable) is
never called on a DisconnectAwareConnection, it's receive() method will never return null as it will block indefinitely.
| Modifier and Type | Method and Description |
|---|---|
Runnable |
onDisconnect(Runnable disconnectAction)
Used to specify the action to take when a disconnection is detected.
|
requestStopRunnable onDisconnect(Runnable disconnectAction)
It is guaranteed that calling receive() on this connection will forever return null after
the disconnect action has been started.
If this connection has an associates disconnect action at the time a disconnection is detected, it is guaranteed
to be invoked before any call to receive() will return null.
If the stop() method is called on this connection before a disconnection is detected, the disconnect action
will never be called.
disconnectAction - The action to perform on disconnection, or null to remove any existing action.null if no action had been previously registered.Copyright © 2013. All rights reserved