Class OnOffSemaphore


  • public class OnOffSemaphore
    extends Object
    A semaphore to answer whether processing is turned on or not at the moment.
    • Constructor Detail

      • OnOffSemaphore

        public OnOffSemaphore()
    • Method Detail

      • isOn

        public boolean isOn()
        Returns whether or not processing is on.
        Returns:
        whether or not processing is on
      • awaitOn

        public boolean awaitOn​(long timeout,
                               TimeUnit unit)
                        throws InterruptedException
        Blocks until processing is turned back on through setOn(boolean) or until the timeout occurs.
        Parameters:
        timeout - the time to wait
        unit - the unit of time
        Returns:
        if on after wait
        Throws:
        InterruptedException - if interrupted