Package org.redisson.api
Interface RLockRx
-
public interface RLockRxRxJava2 interface for Lock object- Author:
- Nikita Koksharov
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description io.reactivex.rxjava3.core.Single<Boolean>forceUnlock()Unlocks the lock independently of its stateio.reactivex.rxjava3.core.Single<Integer>getHoldCount()Number of holds on this lock by the current threadStringgetName()Returns name of objectio.reactivex.rxjava3.core.Single<Boolean>isLocked()Checks if the lock locked by any threadio.reactivex.rxjava3.core.Completablelock()Acquires the lock.io.reactivex.rxjava3.core.Completablelock(long threadId)Acquires the lock by thread with definedthreadId.io.reactivex.rxjava3.core.Completablelock(long leaseTime, TimeUnit unit)Acquires the lock with definedleaseTime.io.reactivex.rxjava3.core.Completablelock(long leaseTime, TimeUnit unit, long threadId)Acquires the lock with definedleaseTimeandthreadId.io.reactivex.rxjava3.core.Single<Long>remainTimeToLive()Remaining time to live of the lockio.reactivex.rxjava3.core.Single<Boolean>tryLock()Tries to acquire the lock.io.reactivex.rxjava3.core.Single<Boolean>tryLock(long threadId)Tries to acquire the lock by thread with specifiedthreadId.io.reactivex.rxjava3.core.Single<Boolean>tryLock(long waitTime, long leaseTime, TimeUnit unit)Tries to acquire the lock with definedleaseTime.io.reactivex.rxjava3.core.Single<Boolean>tryLock(long waitTime, long leaseTime, TimeUnit unit, long threadId)Tries to acquire the lock by thread with specifiedthreadIdandleaseTime.io.reactivex.rxjava3.core.Single<Boolean>tryLock(long waitTime, TimeUnit unit)Tries to acquire the lock.io.reactivex.rxjava3.core.Completableunlock()Unlocks the lockio.reactivex.rxjava3.core.Completableunlock(long threadId)Unlocks the lock.
-
-
-
Method Detail
-
getName
String getName()
Returns name of object- Returns:
- name - name of object
-
forceUnlock
io.reactivex.rxjava3.core.Single<Boolean> forceUnlock()
Unlocks the lock independently of its state- Returns:
trueif lock existed and now unlocked otherwisefalse
-
unlock
io.reactivex.rxjava3.core.Completable unlock()
Unlocks the lock- Returns:
- void
-
unlock
io.reactivex.rxjava3.core.Completable unlock(long threadId)
Unlocks the lock. ThrowsIllegalMonitorStateExceptionif lock isn't locked by thread with specifiedthreadId.- Parameters:
threadId- id of thread- Returns:
- void
-
tryLock
io.reactivex.rxjava3.core.Single<Boolean> tryLock()
Tries to acquire the lock.- Returns:
trueif lock acquired otherwisefalse
-
lock
io.reactivex.rxjava3.core.Completable lock()
Acquires the lock. Waits if necessary until lock became available.- Returns:
- void
-
lock
io.reactivex.rxjava3.core.Completable lock(long threadId)
Acquires the lock by thread with definedthreadId. Waits if necessary until lock became available.- Parameters:
threadId- id of thread- Returns:
- void
-
lock
io.reactivex.rxjava3.core.Completable lock(long leaseTime, TimeUnit unit)Acquires the lock with definedleaseTime. Waits if necessary until lock became available. Lock will be released automatically after definedleaseTimeinterval.- 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
-
lock
io.reactivex.rxjava3.core.Completable lock(long leaseTime, TimeUnit unit, long threadId)Acquires the lock with definedleaseTimeandthreadId. Waits if necessary until lock became available. Lock will be released automatically after definedleaseTimeinterval.- 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
-
tryLock
io.reactivex.rxjava3.core.Single<Boolean> tryLock(long threadId)
Tries to acquire the lock by thread with specifiedthreadId.- Parameters:
threadId- id of thread- Returns:
trueif lock acquired otherwisefalse
-
tryLock
io.reactivex.rxjava3.core.Single<Boolean> tryLock(long waitTime, TimeUnit unit)
Tries to acquire the lock. Waits up to definedwaitTimeif necessary until the lock became available.- Parameters:
waitTime- the maximum time to acquire the lockunit- time unit- Returns:
trueif lock is successfully acquired, otherwisefalseif lock is already set.
-
tryLock
io.reactivex.rxjava3.core.Single<Boolean> tryLock(long waitTime, long leaseTime, TimeUnit unit)
Tries to acquire the lock with definedleaseTime. Waits up to definedwaitTimeif necessary until the lock became available. Lock will be released automatically after definedleaseTimeinterval.- Parameters:
waitTime- the maximum time to acquire the lockleaseTime- lease timeunit- time unit- Returns:
trueif lock is successfully acquired, otherwisefalseif lock is already set.
-
tryLock
io.reactivex.rxjava3.core.Single<Boolean> tryLock(long waitTime, long leaseTime, TimeUnit unit, long threadId)
Tries to acquire the lock by thread with specifiedthreadIdandleaseTime. Waits up to definedwaitTimeif necessary until the lock became available. Lock will be released automatically after definedleaseTimeinterval.- Parameters:
threadId- id of threadwaitTime- time interval to acquire lockleaseTime- time interval after which lock will be released automaticallyunit- the time unit of thewaitTimeandleaseTimearguments- Returns:
trueif lock acquired otherwisefalse
-
getHoldCount
io.reactivex.rxjava3.core.Single<Integer> getHoldCount()
Number of holds on this lock by the current thread- Returns:
- holds or
0if this lock is not held by current thread
-
isLocked
io.reactivex.rxjava3.core.Single<Boolean> isLocked()
Checks if the lock locked by any thread- Returns:
trueif locked otherwisefalse
-
remainTimeToLive
io.reactivex.rxjava3.core.Single<Long> remainTimeToLive()
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.
-
-