Class LoomLinearizableLatch
java.lang.Object
com.loomcache.client.LoomLinearizableLatch
Client-side distributed countdown latch proxy backed by the CP subsystem.
The latch is linearizable: count changes are ordered through Raft, and reads
use the server's linearizable-read path. A latch can be armed with
trySetCount(long) when its current count is zero, decremented with
countDown(), and waited on with await(Duration).
- Since:
- 1.4
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoidawait()Waits until the latch reaches zero.booleanWaits until the latch reaches zero or the timeout expires.booleanWaits until the latch reaches zero or the timeout expires.voidDecrements the latch count by one if it is above zero.longgetCount()Returns the current count.booleantrySetCount(long count) Arms the latch if it can be set to the requested count.
-
Method Details
-
trySetCount
public boolean trySetCount(long count) Arms the latch if it can be set to the requested count.- Parameters:
count- the new count, must be non-negative- Returns:
- true when the count changed, false otherwise
-
countDown
public void countDown()Decrements the latch count by one if it is above zero. -
await
public void await()Waits until the latch reaches zero. -
await
Waits until the latch reaches zero or the timeout expires.- Parameters:
timeout- maximum time to wait- Returns:
- true if the latch reached zero, false if the timeout expired
-
await
Waits until the latch reaches zero or the timeout expires.- Parameters:
timeout- maximum time to waitunit- timeout unit- Returns:
- true if the latch reached zero, false if the timeout expired
-
getCount
public long getCount()Returns the current count.
-