Class TimeoutBlockingWaitStrategy

java.lang.Object
org.apache.logging.log4j.async.logger.internal.TimeoutBlockingWaitStrategy
All Implemented Interfaces:
com.lmax.disruptor.WaitStrategy

public class TimeoutBlockingWaitStrategy extends Object implements com.lmax.disruptor.WaitStrategy
Blocking strategy that uses a lock and condition variable for EventProcessors waiting on a barrier. However, it will periodically wake up if it has been idle for specified period by throwing a TimeoutException. To make use of this, the event handler class should override EventHandlerBase.onTimeout(long), which the BatchEventProcessor will call if the timeout occurs.

This strategy can be used when throughput and low-latency are not as important as CPU resource.

  • Constructor Details

    • TimeoutBlockingWaitStrategy

      public TimeoutBlockingWaitStrategy(long timeout, TimeUnit units)
      Parameters:
      timeout - how long to wait before waking up
      units - the unit in which timeout is specified
  • Method Details

    • waitFor

      public long waitFor(long sequence, com.lmax.disruptor.Sequence cursorSequence, com.lmax.disruptor.Sequence dependentSequence, com.lmax.disruptor.SequenceBarrier barrier) throws com.lmax.disruptor.AlertException, InterruptedException, com.lmax.disruptor.TimeoutException
      Specified by:
      waitFor in interface com.lmax.disruptor.WaitStrategy
      Throws:
      com.lmax.disruptor.AlertException
      InterruptedException
      com.lmax.disruptor.TimeoutException
    • signalAllWhenBlocking

      public void signalAllWhenBlocking()
      Specified by:
      signalAllWhenBlocking in interface com.lmax.disruptor.WaitStrategy
    • toString

      public String toString()
      Overrides:
      toString in class Object