Class ConcurrentBooleanLatch


  • public class ConcurrentBooleanLatch
    extends java.lang.Object
    Similar to a CountDownLatch but allows another thread to open or close the latch (resettable). Unlike a semaphore this is a basic boolean.
    Author:
    jjlauer
    • Constructor Summary

      Constructors 
      Constructor Description
      ConcurrentBooleanLatch()
      Creates a new instance in the "opened" initial state.
      ConcurrentBooleanLatch​(boolean initialValue)
      Creates a new instance in the specified initial state
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void await​(boolean value)
      Will either proceed immediately or wait until the value is set.
      boolean await​(boolean value, long timeout, java.util.concurrent.TimeUnit tu)
      Will either proceed immediately or wait until the value is set.
      boolean await​(boolean value, long timeout, java.util.concurrent.TimeUnit tu, java.lang.Runnable willWait)
      Will either proceed immediately or wait until the value is set.
      void await​(boolean value, java.lang.Runnable willWait)
      Will either proceed immediately or wait until the value is set.
      boolean get()  
      void set​(boolean newValue)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ConcurrentBooleanLatch

        public ConcurrentBooleanLatch()
        Creates a new instance in the "opened" initial state.
      • ConcurrentBooleanLatch

        public ConcurrentBooleanLatch​(boolean initialValue)
        Creates a new instance in the specified initial state
        Parameters:
        initialValue - The initial state
    • Method Detail

      • get

        public boolean get()
      • set

        public void set​(boolean newValue)
      • await

        public void await​(boolean value)
                   throws java.lang.InterruptedException
        Will either proceed immediately or wait until the value is set.
        Parameters:
        value - The value we expect
        Throws:
        java.lang.InterruptedException
      • await

        public void await​(boolean value,
                          java.lang.Runnable willWait)
                   throws java.lang.InterruptedException
        Will either proceed immediately or wait until the value is set.
        Parameters:
        value - The value we expect
        willWait - Will be run only if waiting will be required
        Throws:
        java.lang.InterruptedException
      • await

        public boolean await​(boolean value,
                             long timeout,
                             java.util.concurrent.TimeUnit tu)
                      throws java.lang.InterruptedException
        Will either proceed immediately or wait until the value is set.
        Parameters:
        value - The value we expect
        timeout - Amount of time to wait
        tu - The unit for the timeout
        Returns:
        True is the expected value was met or false if the timeout occurred
        Throws:
        java.lang.InterruptedException
      • await

        public boolean await​(boolean value,
                             long timeout,
                             java.util.concurrent.TimeUnit tu,
                             java.lang.Runnable willWait)
                      throws java.lang.InterruptedException
        Will either proceed immediately or wait until the value is set.
        Parameters:
        value - The value we expect
        timeout - Amount of time to wait
        tu - The unit for the timeout
        willWait - Will be run only if waiting will be required
        Returns:
        True is the expected value was met or false if the timeout occurred
        Throws:
        java.lang.InterruptedException