Class LoomLinearizableLatch

java.lang.Object
com.loomcache.client.LoomLinearizableLatch

public final class LoomLinearizableLatch extends Object
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 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

      public boolean await(Duration timeout)
      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

      public boolean await(long timeout, TimeUnit unit)
      Waits until the latch reaches zero or the timeout expires.
      Parameters:
      timeout - maximum time to wait
      unit - timeout unit
      Returns:
      true if the latch reached zero, false if the timeout expired
    • getCount

      public long getCount()
      Returns the current count.