com.lmax.disruptor
Class WaitStrategy.YieldingStrategy
java.lang.Object
com.lmax.disruptor.WaitStrategy.YieldingStrategy
- All Implemented Interfaces:
- WaitStrategy
- Enclosing interface:
- WaitStrategy
public static final class WaitStrategy.YieldingStrategy
- extends java.lang.Object
- implements WaitStrategy
Yielding strategy that uses a Thread.yield() for Consumer
s waiting on a barrier.
This strategy is a good compromise between performance and CPU resource.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
WaitStrategy.YieldingStrategy
public WaitStrategy.YieldingStrategy()
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 firstringBuffer
- 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 firstringBuffer
- 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.