Modifier and Type | Class and Description |
---|---|
static class |
RedissonLock.LockValue |
Modifier | Constructor and Description |
---|---|
protected |
RedissonLock(ConnectionManager connectionManager,
String name,
UUID id) |
Modifier and Type | Method and Description |
---|---|
void |
delete()
Deletes the object
|
void |
forceUnlock()
Unlocks lock independently of state
|
int |
getHoldCount()
Number of holds on this lock by the current thread
|
String |
getName()
Returns name of object
|
boolean |
isHeldByCurrentThread()
Checks if this lock is held by the current thread
|
boolean |
isLocked()
Checks if this lock locked by any thread in Redisson cluster
|
void |
lock() |
void |
lock(long leaseTime,
TimeUnit unit)
Acquires the lock.
|
void |
lockInterruptibly() |
void |
lockInterruptibly(long leaseTime,
TimeUnit unit)
Acquires the lock.
|
Condition |
newCondition() |
protected <V> io.netty.util.concurrent.Promise<V> |
newPromise() |
boolean |
tryLock() |
boolean |
tryLock(long waitTime,
long leaseTime,
TimeUnit unit)
Returns
true as soon as the lock is acquired. |
boolean |
tryLock(long time,
TimeUnit unit) |
void |
unlock() |
protected RedissonLock(ConnectionManager connectionManager, String name, UUID id)
public void lock(long leaseTime, TimeUnit unit)
RLock
If the lock is not available then the current thread becomes
disabled for thread scheduling purposes and lies dormant until the
lock has been acquired.
If the lock is acquired, it is held until unlock
is invoked,
or until leaseTime milliseconds have passed
since the lock was granted - whichever comes first.
lock
in interface RLock
leaseTime
- the maximum time to hold the lock after granting it,
before automatically releasing it if it hasn't already been released by invoking unlock
.
If leaseTime is -1, hold the lock until explicitly unlocked.unit
- the time unit of the leaseTime
argumentpublic void lockInterruptibly() throws InterruptedException
lockInterruptibly
in interface Lock
InterruptedException
public void lockInterruptibly(long leaseTime, TimeUnit unit) throws InterruptedException
RLock
If the lock is not available then the current thread becomes
disabled for thread scheduling purposes and lies dormant until the
lock has been acquired.
If the lock is acquired, it is held until unlock
is invoked,
or until leaseTime have passed
since the lock was granted - whichever comes first.
lockInterruptibly
in interface RLock
leaseTime
- the maximum time to hold the lock after granting it,
before automatically releasing it if it hasn't already been released by invoking unlock
.
If leaseTime is -1, hold the lock until explicitly unlocked.unit
- the time unit of the leaseTime
argumentInterruptedException
- - if the thread is interrupted before or during this method.public boolean tryLock(long waitTime, long leaseTime, TimeUnit unit) throws InterruptedException
RLock
true
as soon as the lock is acquired.
If the lock is currently held by another thread in this or any
other process in the distributed system this method keeps trying
to acquire the lock for up to waitTime
before
giving up and returning false
. If the lock is acquired,
it is held until unlock
is invoked, or until leaseTime
have passed since the lock was granted - whichever comes first.tryLock
in interface RLock
waitTime
- the maximum time to aquire the lockInterruptedException
public boolean tryLock(long time, TimeUnit unit) throws InterruptedException
tryLock
in interface Lock
InterruptedException
public Condition newCondition()
newCondition
in interface Lock
public void forceUnlock()
RLock
forceUnlock
in interface RLock
public boolean isLocked()
RLock
public boolean isHeldByCurrentThread()
RLock
isHeldByCurrentThread
in interface RLock
true
if held by current thread
otherwise false
public int getHoldCount()
RLock
getHoldCount
in interface RLock
0
if this lock is not held by current threadpublic void delete()
RObject
protected <V> io.netty.util.concurrent.Promise<V> newPromise()
Copyright © 2014–2015. All rights reserved.