Added reactive version of FairLock. #1554

pull/1547/head
Nikita 7 years ago
parent 13305dfcbc
commit 4a7f63051c

@ -24,7 +24,7 @@ import org.redisson.api.RLock;
import org.redisson.client.codec.LongCodec;
import org.redisson.client.protocol.RedisCommands;
import org.redisson.client.protocol.RedisStrictCommand;
import org.redisson.command.CommandExecutor;
import org.redisson.command.CommandAsyncExecutor;
import org.redisson.pubsub.LockPubSub;
/**
@ -40,11 +40,11 @@ import org.redisson.pubsub.LockPubSub;
public class RedissonFairLock extends RedissonLock implements RLock {
private final long threadWaitTime = 5000;
private final CommandExecutor commandExecutor;
private final CommandAsyncExecutor commandExecutor;
private final String threadsQueueName;
private final String timeoutSetName;
protected RedissonFairLock(CommandExecutor commandExecutor, String name) {
protected RedissonFairLock(CommandAsyncExecutor commandExecutor, String name) {
super(commandExecutor, name);
this.commandExecutor = commandExecutor;
threadsQueueName = prefixName("redisson_lock_queue", name);

@ -120,6 +120,11 @@ public class RedissonReactive implements RedissonReactiveClient {
codecProvider = config.getReferenceCodecProvider();
}
@Override
public RLockReactive getFairLock(String name) {
return new RedissonLockReactive(commandExecutor, name, new RedissonFairLock(commandExecutor, name));
}
@Override
public RRateLimiterReactive getRateLimiter(String name) {
return new RedissonRateLimiterReactive(commandExecutor, name);

@ -63,6 +63,16 @@ public interface RedissonReactiveClient {
*/
RReadWriteLockReactive getReadWriteLock(String name);
/**
* Returns lock instance by name.
* <p>
* Implements a <b>fair</b> locking so it guarantees an acquire order by threads.
*
* @param name - name of object
* @return Lock object
*/
RLockReactive getFairLock(String name);
/**
* Returns lock instance by name.
* <p>

Loading…
Cancel
Save