Package com.lmax.disruptor
Class ProcessingSequenceBarrier
java.lang.Object
com.lmax.disruptor.ProcessingSequenceBarrier
- All Implemented Interfaces:
SequenceBarrier
SequenceBarrier handed out for gating EventProcessors on a cursor sequence and optional dependent EventProcessor(s),
using the given WaitStrategy.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate final Sequenceprivate final Sequenceprivate final Sequencerprivate final WaitStrategy -
Constructor Summary
ConstructorsConstructorDescriptionProcessingSequenceBarrier(Sequencer sequencer, WaitStrategy waitStrategy, Sequence cursorSequence, Sequence[] dependentSequences) -
Method Summary
Modifier and TypeMethodDescriptionvoidalert()Alert theEventProcessors of a status change and stay in this status until cleared.voidCheck if an alert has been raised and throw anAlertExceptionif it has.voidClear the current alert status.longGet the current cursor value that can be read.booleanThe current alert status for the barrier.longwaitFor(long sequence) Wait for the given sequence to be available for consumption.
-
Field Details
-
waitStrategy
-
dependentSequence
-
alerted
private volatile boolean alerted -
cursorSequence
-
sequencer
-
-
Constructor Details
-
ProcessingSequenceBarrier
ProcessingSequenceBarrier(Sequencer sequencer, WaitStrategy waitStrategy, Sequence cursorSequence, Sequence[] dependentSequences)
-
-
Method Details
-
waitFor
Description 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 DisruptorInterruptedException- 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
Description 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.
-