Package io.atomix.client.lock
Interface AsyncDistributedLock
- All Superinterfaces:
AsyncPrimitive<AsyncDistributedLock,,DistributedLock> DistributedPrimitive
-
Method Summary
Modifier and TypeMethodDescriptionisLocked()Query whether this lock is locked or not.lock()Acquires the lock, blocking until it's available.default DistributedLockReturns a synchronous wrapper around the asynchronous primitive.tryLock()Attempts to acquire the lock.default CompletableFuture<Boolean>Attempts to acquire the lock.Attempts to acquire the lock for a specified amount of time.unlock()Unlocks the lock.Methods inherited from interface io.atomix.client.AsyncPrimitive
close, syncMethods inherited from interface io.atomix.client.DistributedPrimitive
name
-
Method Details
-
lock
CompletableFuture<Void> lock()Acquires the lock, blocking until it's available.- Returns:
- future to be completed once the lock has been acquired
-
tryLock
CompletableFuture<Boolean> tryLock()Attempts to acquire the lock.- Returns:
- future to be completed with a boolean indicating whether the lock was acquired
-
tryLock
Attempts to acquire the lock.- Parameters:
timeout- the timeout after which to give up attempting to acquire the lockunit- the timeout time unit- Returns:
- future to be completed with a boolean indicating whether the lock was acquired
-
tryLock
Attempts to acquire the lock for a specified amount of time.- Parameters:
timeout- the timeout after which to give up attempting to acquire the lock- Returns:
- future to be completed with a boolean indicating whether the lock was acquired
-
unlock
CompletableFuture<Void> unlock()Unlocks the lock.- Returns:
- future to be completed once the lock has been released
-
isLocked
CompletableFuture<Boolean> isLocked()Query whether this lock is locked or not.- Returns:
- future to be completed with a boolean indicating whether the lock was locked or not
-
sync
Description copied from interface:AsyncPrimitiveReturns a synchronous wrapper around the asynchronous primitive.- Specified by:
syncin interfaceAsyncPrimitive<AsyncDistributedLock,DistributedLock> - Parameters:
operationTimeout- the synchronous operation timeout- Returns:
- the synchronous primitive
-