com.lmax.disruptor
Class WaitStrategy.BusySpinStrategy
java.lang.Object
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 Consumer
s 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.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
WaitStrategy.BusySpinStrategy
public WaitStrategy.BusySpinStrategy()
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.