All Downloads are FREE. Search and download functionalities are using the official Maven repository.

redis.netty4.ChannelFutureListenerPromiseAdapter Maven / Gradle / Ivy

The newest version!
package redis.netty4;

import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import spullara.util.concurrent.Promise;

/**
 * Adapts a ChannelFutureListener to a Promise.
 */
public class ChannelFutureListenerPromiseAdapter implements ChannelFutureListener {
  private final Promise promise;
  private final T client;


  public ChannelFutureListenerPromiseAdapter(Promise promise, T client) {
    this.promise = promise;
    this.client = client;
  }

  @Override
  public void operationComplete(ChannelFuture channelFuture) throws Exception {
    if (channelFuture.isSuccess()) {
      promise.set(client);
    } else {
      promise.setException(channelFuture.cause());
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy