Skip to content

Commit

Permalink
SuccessFuture allocation optimization. #338
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikita committed Dec 18, 2015
1 parent e17a9ce commit ca6be04
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
6 changes: 6 additions & 0 deletions src/main/java/org/redisson/client/RedisConnection.java
Expand Up @@ -23,6 +23,7 @@
import org.redisson.client.protocol.RedisCommand;
import org.redisson.client.protocol.RedisCommands;
import org.redisson.client.protocol.RedisStrictCommand;
import org.redisson.connection.FastSuccessFuture;

import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
Expand All @@ -44,6 +45,7 @@ public class RedisConnection implements RedisCommands {
private ReconnectListener reconnectListener;
private long lastUsageTime;

private final Future<?> acquireFuture = new FastSuccessFuture<Object>(this);

public RedisConnection(RedisClient redisClient, Channel channel) {
super();
Expand Down Expand Up @@ -194,4 +196,8 @@ public String toString() {
return getClass().getSimpleName() + " [redisClient=" + redisClient + ", channel=" + channel + "]";
}

public Future<?> getAcquireFuture() {
return acquireFuture;
}

}
2 changes: 0 additions & 2 deletions src/main/java/org/redisson/client/RedisPubSubConnection.java
Expand Up @@ -33,8 +33,6 @@

import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.util.concurrent.Future;
import io.netty.util.concurrent.FutureListener;
import io.netty.util.internal.PlatformDependent;

public class RedisPubSubConnection extends RedisConnection {
Expand Down
Expand Up @@ -25,7 +25,7 @@ public class FastSuccessFuture<V> extends FastCompleteFuture<V> {

private final V result;

protected FastSuccessFuture(V result) {
public FastSuccessFuture(V result) {
this.result = result;
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/redisson/misc/ConnectionPool.java
Expand Up @@ -193,7 +193,7 @@ private void promiseSuccessful(ClientConnectionsEntry entry, Promise<T> promise,

private Future<T> promiseSuccessful(ClientConnectionsEntry entry, T conn) {
entry.resetFailedAttempts();
return connectionManager.newSucceededFuture(conn);
return (Future<T>) conn.getAcquireFuture();
}

private void promiseFailure(ClientConnectionsEntry entry, Promise<T> promise, Throwable cause) {
Expand Down

0 comments on commit ca6be04

Please sign in to comment.