Package ghidra.util

Class CountLatch


  • public class CountLatch
    extends java.lang.Object
    Latch that has a count that can be incremented and decremented. Threads that call await() will block until the count is 0.
    • Constructor Summary

      Constructors 
      Constructor Description
      CountLatch()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void await()
      Causes the current thread to wait until the latch count is zero, unless the thread is interrupted.
      boolean await​(long timeout, java.util.concurrent.TimeUnit unit)
      Causes the current thread to wait until the latch count is zero, unless the thread is interrupted, or the specified waiting time elapses.
      void decrement()
      Decrements the latch count and releases any waiting threads when the count reaches 0.
      int getCount()  
      void increment()
      Increments the latch count.
      • Methods inherited from class java.lang.Object

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

      • CountLatch

        public CountLatch()
    • Method Detail

      • increment

        public void increment()
        Increments the latch count.
      • decrement

        public void decrement()
        Decrements the latch count and releases any waiting threads when the count reaches 0.
      • getCount

        public int getCount()
      • await

        public void await()
                   throws java.lang.InterruptedException
        Causes the current thread to wait until the latch count is zero, unless the thread is interrupted.

        If the current count is zero then this method returns immediately.

        If the current count is greater than zero then the current thread becomes disabled for thread scheduling purposes and lies dormant until one of two things happen:

        • The count reaches zero due to invocations of the decrement() method; or
        • Some other thread interrupts the current thread.

        If the current thread:

        • has its interrupted status set on entry to this method; or
        • is interrupted while waiting,
        then InterruptedException is thrown and the current thread's interrupted status is cleared.
        Throws:
        java.lang.InterruptedException - if the current thread is interrupted while waiting
      • await

        public boolean await​(long timeout,
                             java.util.concurrent.TimeUnit unit)
                      throws java.lang.InterruptedException
        Causes the current thread to wait until the latch count is zero, unless the thread is interrupted, or the specified waiting time elapses.

        If the current count is zero then this method returns immediately with the value true.

        If the current count is greater than zero then the current thread becomes disabled for thread scheduling purposes and lies dormant until one of three things happen:

        • The count reaches zero due to invocations of the decrement() method; or
        • Some other thread interrupts the current thread; or
        • The specified waiting time elapses.

        If the count reaches zero then the method returns with the value true.

        If the current thread:

        • has its interrupted status set on entry to this method; or
        • is interrupted while waiting,
        then InterruptedException is thrown and the current thread's interrupted status is cleared.

        If the specified waiting time elapses then the value false is returned. If the time is less than or equal to zero, the method will not wait at all.

        Parameters:
        timeout - the maximum time to wait
        unit - the time unit of the timeout argument
        Returns:
        true if the count reached zero and false if the waiting time elapsed before the count reached zero
        Throws:
        java.lang.InterruptedException - if the current thread is interrupted while waiting