Class ExponentionallyIncreasingSleepingWaitStrategy

  • All Implemented Interfaces:
    com.lmax.disruptor.WaitStrategy

    public final class ExponentionallyIncreasingSleepingWaitStrategy
    extends java.lang.Object
    implements com.lmax.disruptor.WaitStrategy
    Sleeping strategy that sleeps (LockSupport.parkNanos(n)) for an linearly increasing number of nanos while the EventProcessors are waiting on a barrier.

    This strategy consumes very little CPU resources. However, latency spikes up to sleepTimeNsMax will occur. It will also reduce the impact on the producing thread as it will not need signal any conditional variables to wake up the event handling thread.

    The agent does not require to transfer events with low latency from producers to the consumer. The primary concerns are low latency for adding events (to not block application threads) and low CPU consumption. It does not matter if handling the events is a bit delayed. The only caveat is that sudden traffic spikes after quiet periods can lead to loosing events. If that should become a problem, take a look at the approaches outlined in https://github.com/LMAX-Exchange/disruptor/issues/246 and https://github.com/census-instrumentation/opencensus-java/pull/1618. In situations where the consumer is overloaded (always busy and awake) this wait strategy actually has very good latency because consumers don't have to signal.

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void signalAllWhenBlocking()  
      long waitFor​(long sequence, com.lmax.disruptor.Sequence cursor, com.lmax.disruptor.Sequence dependentSequence, com.lmax.disruptor.SequenceBarrier barrier)  
      • Methods inherited from class java.lang.Object

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

      • ExponentionallyIncreasingSleepingWaitStrategy

        public ExponentionallyIncreasingSleepingWaitStrategy​(int sleepTimeNsStart,
                                                             int sleepTimeNsMax)
    • Method Detail

      • waitFor

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

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