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
SequenceBarrierhanded out for gatingEventProcessors on a cursor sequence and optional dependentEventProcessor(s), using the given WaitStrategy.
-
-
Field Summary
Fields Modifier and Type Field Description private booleanalertedprivate SequencecursorSequenceprivate SequencedependentSequenceprivate Sequencersequencerprivate WaitStrategywaitStrategy
-
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 voidalert()Alert theEventProcessors of a status change and stay in this status until cleared.voidcheckAlert()Check if an alert has been raised and throw anAlertExceptionif it has.voidclearAlert()Clear the current alert status.longgetCursor()Get the current cursor value that can be read.booleanisAlerted()The current alert status for the barrier.longwaitFor(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, TimeoutExceptionDescription copied from interface:SequenceBarrierWait for the given sequence to be available for consumption.- Specified by:
waitForin 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:SequenceBarrierGet the current cursor value that can be read.- Specified by:
getCursorin interfaceSequenceBarrier- Returns:
- value of the cursor for entries that have been published.
-
isAlerted
public boolean isAlerted()
Description copied from interface:SequenceBarrierThe current alert status for the barrier.- Specified by:
isAlertedin interfaceSequenceBarrier- Returns:
- true if in alert otherwise false.
-
alert
public void alert()
Description copied from interface:SequenceBarrierAlert theEventProcessors of a status change and stay in this status until cleared.- Specified by:
alertin interfaceSequenceBarrier
-
clearAlert
public void clearAlert()
Description copied from interface:SequenceBarrierClear the current alert status.- Specified by:
clearAlertin interfaceSequenceBarrier
-
checkAlert
public void checkAlert() throws AlertExceptionDescription copied from interface:SequenceBarrierCheck if an alert has been raised and throw anAlertExceptionif it has.- Specified by:
checkAlertin interfaceSequenceBarrier- Throws:
AlertException- if alert has been raised.
-
-