com.lmax.disruptor
Class WaitStrategy.BlockingStrategy

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

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

Blocking strategy that uses a lock and condition variable for Consumers waiting on a barrier. This strategy should be used when performance and low-latency are not as important as CPU resource.


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.lmax.disruptor.WaitStrategy
WaitStrategy.BlockingStrategy, WaitStrategy.BusySpinStrategy, WaitStrategy.Option, WaitStrategy.YieldingStrategy
 
Constructor Summary
WaitStrategy.BlockingStrategy()
           
 
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.BlockingStrategy

public WaitStrategy.BlockingStrategy()
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.