Class ConditionLatch

java.lang.Object
de.aristaflow.adept2.util.locking.ConditionLatch

public class ConditionLatch extends Object
This is similar to a normal CountDownLatch but it uses a wrapped lock for synchronising as well as a new corresponding condition for signalling. This allows to have a latch that releases a lock when waiting for the latch.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final Condition
    The condition on which to wait for the latch.
    protected long
    The number of releases before this latch releases threads.
    protected final Lock
    The lock which to use for synchronising.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new latch with the designated latch and a count of 1.
    ConditionLatch(Lock lock, long count)
    Creates a new latch with the designated latch and the designated count.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    boolean
    await(long timeout, TimeUnit unit)
     
    void
     
    long
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • lock

      protected final Lock lock
      The lock which to use for synchronising.
    • cond

      protected final Condition cond
      The condition on which to wait for the latch.
    • count

      protected long count
      The number of releases before this latch releases threads.
  • Constructor Details

    • ConditionLatch

      public ConditionLatch(Lock lock)
      Creates a new latch with the designated latch and a count of 1.
      Parameters:
      lock - The lock with which to synchronise access to this latch.
    • ConditionLatch

      public ConditionLatch(Lock lock, long count)
      Creates a new latch with the designated latch and the designated count.
      Parameters:
      lock - The lock with which to synchronise access to this latch.
      count - The number of releases before this latch releases threads.
  • Method Details