Package org.redisson.api
Interface RLockAsync
- All Known Subinterfaces:
RFencedLock
,RFencedLockAsync
,RLock
- All Known Implementing Classes:
RedissonBaseLock
,RedissonFairLock
,RedissonFencedLock
,RedissonLock
,RedissonMultiLock
,RedissonReadLock
,RedissonRedLock
,RedissonSpinLock
,RedissonTransactionalLock
,RedissonTransactionalReadLock
,RedissonTransactionalWriteLock
,RedissonWriteLock
public interface RLockAsync
Async interface for Lock object
- Author:
- Nikita Koksharov
-
Method Summary
Modifier and TypeMethodDescriptionUnlocks the lock independently of its stateNumber of holds on this lock by the current threadisHeldByThreadAsync
(long threadId) Checks if the lock is held by thread with definedthreadId
Checks if the lock locked by any threadAcquires the lock.lockAsync
(long threadId) Acquires the lock by thread with definedthreadId
.Acquires the lock with definedleaseTime
.Acquires the lock with definedleaseTime
andthreadId
.Remaining time to live of the lockTries to acquire the lock.tryLockAsync
(long threadId) Tries to acquire the lock by thread with specifiedthreadId
.tryLockAsync
(long waitTime, long leaseTime, TimeUnit unit) Tries to acquire the lock with definedleaseTime
.tryLockAsync
(long waitTime, long leaseTime, TimeUnit unit, long threadId) Tries to acquire the lock by thread with specifiedthreadId
andleaseTime
.tryLockAsync
(long waitTime, TimeUnit unit) Tries to acquire the lock.Unlocks the lockunlockAsync
(long threadId) Unlocks the lock.
-
Method Details
-
forceUnlockAsync
Unlocks the lock independently of its state- Returns:
true
if lock existed and now unlocked otherwisefalse
-
unlockAsync
Unlocks the lock- Returns:
- void
-
unlockAsync
Unlocks the lock. ThrowsIllegalMonitorStateException
if lock isn't locked by thread with specifiedthreadId
.- Parameters:
threadId
- id of thread- Returns:
- void
-
tryLockAsync
Tries to acquire the lock.- Returns:
true
if lock acquired otherwisefalse
-
lockAsync
Acquires the lock. Waits if necessary until lock became available.- Returns:
- void
-
lockAsync
Acquires the lock by thread with definedthreadId
. Waits if necessary until lock became available.- Parameters:
threadId
- id of thread- Returns:
- void
-
lockAsync
Acquires the lock with definedleaseTime
. Waits if necessary until lock became available. Lock will be released automatically after definedleaseTime
interval.- Parameters:
leaseTime
- the maximum time to hold the lock after it's acquisition, if it hasn't already been released by invokingunlock
. If leaseTime is -1, hold the lock until explicitly unlocked.unit
- the time unit- Returns:
- void
-
lockAsync
Acquires the lock with definedleaseTime
andthreadId
. Waits if necessary until lock became available. Lock will be released automatically after definedleaseTime
interval.- Parameters:
leaseTime
- the maximum time to hold the lock after it's acquisition, if it hasn't already been released by invokingunlock
. If leaseTime is -1, hold the lock until explicitly unlocked.unit
- the time unitthreadId
- id of thread- Returns:
- void
-
tryLockAsync
Tries to acquire the lock by thread with specifiedthreadId
.- Parameters:
threadId
- id of thread- Returns:
true
if lock acquired otherwisefalse
-
tryLockAsync
Tries to acquire the lock. Waits up to definedwaitTime
if necessary until the lock became available.- Parameters:
waitTime
- the maximum time to acquire the lockunit
- time unit- Returns:
true
if lock is successfully acquired, otherwisefalse
if lock is already set.
-
tryLockAsync
Tries to acquire the lock with definedleaseTime
. Waits up to definedwaitTime
if necessary until the lock became available. Lock will be released automatically after definedleaseTime
interval.- Parameters:
waitTime
- the maximum time to acquire the lockleaseTime
- lease timeunit
- time unit- Returns:
true
if lock is successfully acquired, otherwisefalse
if lock is already set.
-
tryLockAsync
Tries to acquire the lock by thread with specifiedthreadId
andleaseTime
. Waits up to definedwaitTime
if necessary until the lock became available. Lock will be released automatically after definedleaseTime
interval.- Parameters:
waitTime
- time interval to acquire lockleaseTime
- time interval after which lock will be released automaticallyunit
- the time unit of thewaitTime
andleaseTime
argumentsthreadId
- id of thread- Returns:
true
if lock acquired otherwisefalse
-
isHeldByThreadAsync
Checks if the lock is held by thread with definedthreadId
- Parameters:
threadId
- Thread ID of locking thread- Returns:
true
if held by thread with given id otherwisefalse
-
getHoldCountAsync
Number of holds on this lock by the current thread- Returns:
- holds or
0
if this lock is not held by current thread
-
isLockedAsync
Checks if the lock locked by any thread- Returns:
true
if locked otherwisefalse
-
remainTimeToLiveAsync
Remaining time to live of the lock- Returns:
- time in milliseconds -2 if the lock does not exist. -1 if the lock exists but has no associated expire.
-