Package io.atomix.client.lock
Interface AsyncAtomicLock
- All Superinterfaces:
AsyncPrimitive<AsyncAtomicLock,,AtomicLock> DistributedPrimitive
-
Method Summary
Modifier and TypeMethodDescriptionisLocked()Query whether this lock is locked or not.lock()Acquires the lock, blocking until it's available.default AtomicLockReturns a synchronous wrapper around the asynchronous primitive.tryLock()Attempts to acquire the lock.default CompletableFuture<OptionalLong>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<Long> lock()Acquires the lock, blocking until it's available.- Returns:
- future to be completed once the lock has been acquired
-
tryLock
CompletableFuture<OptionalLong> 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<AsyncAtomicLock,AtomicLock> - Parameters:
operationTimeout- the synchronous operation timeout- Returns:
- the synchronous primitive
-