Package com.lmax.disruptor
Class EventPoller<T>
java.lang.Object
com.lmax.disruptor.EventPoller<T>
- Type Parameters:
T- the type of event used.
Experimental poll-based interface for the Disruptor. Unlike a
BatchEventProcessor,
an event poller allows the user to control the flow of execution. This makes it ideal
for interoperability with existing threads whose lifecycle is not controlled by the
disruptor DSL.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceA callback used to process eventsstatic enumIndicates the result of a call topoll(Handler) -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final DataProvider<T> private final Sequenceprivate final Sequenceprivate final Sequencer -
Constructor Summary
ConstructorsConstructorDescriptionEventPoller(DataProvider<T> dataProvider, Sequencer sequencer, Sequence sequence, Sequence gatingSequence) Creates an event poller. -
Method Summary
Modifier and TypeMethodDescriptionGet theSequencebeing used by this event pollerstatic <T> EventPoller<T> newInstance(DataProvider<T> dataProvider, Sequencer sequencer, Sequence sequence, Sequence cursorSequence, Sequence... gatingSequences) Creates an event poller.poll(EventPoller.Handler<T> eventHandler) Polls for events using the given handler.
-
Field Details
-
dataProvider
-
sequencer
-
sequence
-
gatingSequence
-
-
Constructor Details
-
EventPoller
public EventPoller(DataProvider<T> dataProvider, Sequencer sequencer, Sequence sequence, Sequence gatingSequence) Creates an event poller. Most users will wantRingBuffer.newPoller(Sequence...)which will set up the poller automatically- Parameters:
dataProvider- from which events are drawnsequencer- the main sequencer which handles ordering of eventssequence- the sequence which will be used by this event pollergatingSequence- the sequences to gate on
-
-
Method Details
-
poll
Polls for events using the given handler.
This poller will continue to feed events to the given handler until known available events are consumed orEventPoller.Handler.onEvent(Object, long, boolean)returns false.
Note that it is possible for more events to become available while the current events are being processed. A further call to this method will process such events.- Parameters:
eventHandler- the handler used to consume events- Returns:
- the state of the event poller after the poll is attempted
- Throws:
Exception- exceptions thrown from the event handler are propagated to the caller
-
newInstance
public static <T> EventPoller<T> newInstance(DataProvider<T> dataProvider, Sequencer sequencer, Sequence sequence, Sequence cursorSequence, Sequence... gatingSequences) Creates an event poller. Most users will wantRingBuffer.newPoller(Sequence...)which will set up the poller automatically- Type Parameters:
T- the type of the event- Parameters:
dataProvider- from which events are drawnsequencer- the main sequencer which handles ordering of eventssequence- the sequence which will be used by this event pollercursorSequence- the cursor sequence, usually of the ring buffergatingSequences- additional sequences to gate on- Returns:
- the event poller
-
getSequence
Get theSequencebeing used by this event poller- Returns:
- the sequence used by the event poller
-