public abstract class SubscriberToChannelFutureBridge
extends java.lang.Object
implements io.netty.channel.ChannelFutureListener
Subscriber to a ChannelFuture so that when the subscriber is
unsubscribed, the listener will get removed from the future. Failure to do so for futures that are long
living, eg: Channel.closeFuture() will lead to a memory leak where the attached listener will be in the
listener queue of the future till the channel closes.
In order to bridge the future and subscriber, bridge(ChannelFuture, Subscriber) must be called.| Constructor and Description |
|---|
SubscriberToChannelFutureBridge() |
| Modifier and Type | Method and Description |
|---|---|
void |
bridge(io.netty.channel.ChannelFuture future,
rx.Subscriber<?> subscriber)
Bridges the passed subscriber and future, which means the following:
Add this listener to the passed future.
Add a callback to the subscriber, such that on unsubscribe this listener is removed from the future.
|
protected abstract void |
doOnFailure(io.netty.channel.ChannelFuture future,
java.lang.Throwable cause) |
protected abstract void |
doOnSuccess(io.netty.channel.ChannelFuture future) |
void |
operationComplete(io.netty.channel.ChannelFuture future) |
public final void operationComplete(io.netty.channel.ChannelFuture future)
throws java.lang.Exception
operationComplete in interface io.netty.util.concurrent.GenericFutureListener<io.netty.channel.ChannelFuture>java.lang.Exceptionprotected abstract void doOnSuccess(io.netty.channel.ChannelFuture future)
protected abstract void doOnFailure(io.netty.channel.ChannelFuture future,
java.lang.Throwable cause)
public void bridge(io.netty.channel.ChannelFuture future,
rx.Subscriber<?> subscriber)
future - Future to bridge.subscriber - Subscriber to connect to the future.