Package com.lmax.disruptor
Class ProcessingSequenceBarrier
- java.lang.Object
-
- com.lmax.disruptor.ProcessingSequenceBarrier
-
- All Implemented Interfaces:
SequenceBarrier
final class ProcessingSequenceBarrier extends java.lang.Object implements SequenceBarrier
SequenceBarrier
handed out for gatingEventProcessor
s on a cursor sequence and optional dependentEventProcessor
(s), using the given WaitStrategy.
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
alerted
private Sequence
cursorSequence
private Sequence
dependentSequence
private Sequencer
sequencer
private WaitStrategy
waitStrategy
-
Constructor Summary
Constructors Constructor Description ProcessingSequenceBarrier(Sequencer sequencer, WaitStrategy waitStrategy, Sequence cursorSequence, Sequence[] dependentSequences)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
alert()
Alert theEventProcessor
s of a status change and stay in this status until cleared.void
checkAlert()
Check if an alert has been raised and throw anAlertException
if it has.void
clearAlert()
Clear the current alert status.long
getCursor()
Get the current cursor value that can be read.boolean
isAlerted()
The current alert status for the barrier.long
waitFor(long sequence)
Wait for the given sequence to be available for consumption.
-
-
-
Field Detail
-
waitStrategy
private final WaitStrategy waitStrategy
-
dependentSequence
private final Sequence dependentSequence
-
alerted
private volatile boolean alerted
-
cursorSequence
private final Sequence cursorSequence
-
sequencer
private final Sequencer sequencer
-
-
Constructor Detail
-
ProcessingSequenceBarrier
ProcessingSequenceBarrier(Sequencer sequencer, WaitStrategy waitStrategy, Sequence cursorSequence, Sequence[] dependentSequences)
-
-
Method Detail
-
waitFor
public long waitFor(long sequence) throws AlertException, java.lang.InterruptedException, TimeoutException
Description copied from interface:SequenceBarrier
Wait for the given sequence to be available for consumption.- Specified by:
waitFor
in interfaceSequenceBarrier
- Parameters:
sequence
- to wait for- Returns:
- the sequence up to which is available
- Throws:
AlertException
- if a status change has occurred for the Disruptorjava.lang.InterruptedException
- if the thread needs awaking on a condition variable.TimeoutException
- if a timeout occurs while waiting for the supplied sequence.
-
getCursor
public long getCursor()
Description copied from interface:SequenceBarrier
Get the current cursor value that can be read.- Specified by:
getCursor
in interfaceSequenceBarrier
- Returns:
- value of the cursor for entries that have been published.
-
isAlerted
public boolean isAlerted()
Description copied from interface:SequenceBarrier
The current alert status for the barrier.- Specified by:
isAlerted
in interfaceSequenceBarrier
- Returns:
- true if in alert otherwise false.
-
alert
public void alert()
Description copied from interface:SequenceBarrier
Alert theEventProcessor
s of a status change and stay in this status until cleared.- Specified by:
alert
in interfaceSequenceBarrier
-
clearAlert
public void clearAlert()
Description copied from interface:SequenceBarrier
Clear the current alert status.- Specified by:
clearAlert
in interfaceSequenceBarrier
-
checkAlert
public void checkAlert() throws AlertException
Description copied from interface:SequenceBarrier
Check if an alert has been raised and throw anAlertException
if it has.- Specified by:
checkAlert
in interfaceSequenceBarrier
- Throws:
AlertException
- if alert has been raised.
-
-