Hi Mike,
A simple test with the EventPoller looks pretty good. Just a couple follow up questions. Does this setup code for the test look correct?
AtomicInteger handledEventCounter = new AtomicInteger();
int bufferSize = 2048;
RingBuffer<LongEvent> buffer = RingBuffer.createSingleProducer(factory, bufferSize, strategy);
final EventPoller<LongEvent> poller = buffer.newPoller(new Sequence[0]);
final PollerLongEventHandler handler = new PollerLongEventHandler(STATS, handledEventCounter);
Thread pollerThread = new Thread() {
@Override
public void run() {
try {
LOG.info("thread started");
while (!isInterrupted()) {
PollState state = poller.poll(handler);
// if state is something appropriate, do some periodic work
// if (state == IDLE) {
// readBackChannelQueue();
// }
}
} catch (Exception e) {
e.printStackTrace();
}
}
};
pollerThread.start();
Also, I'm a little confused about what to do with the different PollState return values. Does it really matter what the PollState is as to whether the polling thread dispatches to do additional work? For example,
I can see from the source code, that if you want your handler to consume all available events before exiting the poll method, it should return true. So if it returns true, then whenever the poll method returns you know there are no more consumable events. In that case, I am guessing you can assume you can do other work? (On the other hand, if your handler returns false, then I am guessing PROCESSING is a signal that there
may be more events to consume).
Relating to this, what does the GATING state mean, and also is there any reason if it returns that state, you shouldn't do extra work?
Thanks again and Best Regards,
Sam
On Tuesday, March 3, 2015 at 5:08:20 PM UTC-5, mikeb01 wrote: