com.lmax.disruptor
Class WaitStrategy.BusySpinStrategy

java.lang.Object
  extended by com.lmax.disruptor.WaitStrategy.BusySpinStrategy
All Implemented Interfaces:
WaitStrategy
Enclosing interface:
WaitStrategy

public static final class WaitStrategy.BusySpinStrategy
extends java.lang.Object
implements WaitStrategy

Busy Spin strategy that uses a busy spin loop for Consumers waiting on a barrier. This strategy will use CPU resource to avoid syscalls which can introduce latency jitter. It is best used when threads can be bound to specific CPU cores.


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.lmax.disruptor.WaitStrategy
WaitStrategy.BlockingStrategy, WaitStrategy.BusySpinStrategy, WaitStrategy.Option, WaitStrategy.YieldingStrategy
 
Constructor Summary
WaitStrategy.BusySpinStrategy()
           
 
Method Summary
 void signalAll()
          Signal those waiting that the RingBuffer cursor has advanced.
 long waitFor(Consumer[] consumers, RingBuffer ringBuffer, ConsumerBarrier barrier, long sequence)
          Wait for the given sequence to be available for consumption in a RingBuffer
 long waitFor(Consumer[] consumers, RingBuffer ringBuffer, ConsumerBarrier barrier, long sequence, long timeout, java.util.concurrent.TimeUnit units)
          Wait for the given sequence to be available for consumption in a RingBuffer with a timeout specified.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WaitStrategy.BusySpinStrategy

public WaitStrategy.BusySpinStrategy()
Method Detail

waitFor

public long waitFor(Consumer[] consumers,
                    RingBuffer ringBuffer,
                    ConsumerBarrier barrier,
                    long sequence)
             throws AlertException,
                    java.lang.InterruptedException
Description copied from interface: WaitStrategy
Wait for the given sequence to be available for consumption in a RingBuffer

Specified by:
waitFor in interface WaitStrategy
Parameters:
consumers - further back the chain that must advance first
ringBuffer - on which to wait.
barrier - the consumer is waiting on.
sequence - to be waited on.
Returns:
the sequence that is available which may be greater than the requested sequence.
Throws:
AlertException - if the status of the Disruptor has changed.
java.lang.InterruptedException - if the thread is interrupted.

waitFor

public long waitFor(Consumer[] consumers,
                    RingBuffer ringBuffer,
                    ConsumerBarrier barrier,
                    long sequence,
                    long timeout,
                    java.util.concurrent.TimeUnit units)
             throws AlertException,
                    java.lang.InterruptedException
Description copied from interface: WaitStrategy
Wait for the given sequence to be available for consumption in a RingBuffer with a timeout specified.

Specified by:
waitFor in interface WaitStrategy
Parameters:
consumers - further back the chain that must advance first
ringBuffer - on which to wait.
barrier - the consumer is waiting on.
sequence - to be waited on.
timeout - value to abort after.
units - of the timeout value.
Returns:
the sequence that is available which may be greater than the requested sequence.
Throws:
AlertException - if the status of the Disruptor has changed.
java.lang.InterruptedException - if the thread is interrupted.

signalAll

public void signalAll()
Description copied from interface: WaitStrategy
Signal those waiting that the RingBuffer cursor has advanced.

Specified by:
signalAll in interface WaitStrategy


Copyright © 2011 LMAX Ltd. All Rights Reserved.