use of com.lmax.disruptor.dsl.stubs.TestWorkHandler in project disruptor by LMAX-Exchange.
the class DisruptorTest method shouldProvideEventsToWorkHandlers.
@Test
public void shouldProvideEventsToWorkHandlers() throws Exception {
final TestWorkHandler workHandler1 = createTestWorkHandler();
final TestWorkHandler workHandler2 = createTestWorkHandler();
disruptor.handleEventsWithWorkerPool(workHandler1, workHandler2);
publishEvent();
publishEvent();
workHandler1.processEvent();
workHandler2.processEvent();
}
use of com.lmax.disruptor.dsl.stubs.TestWorkHandler in project disruptor by LMAX-Exchange.
the class DisruptorTest method shouldSupportCombiningWorkerPoolWithEventHandlerAsDependencyWhenNotPreviouslyRegistered.
@Test
public void shouldSupportCombiningWorkerPoolWithEventHandlerAsDependencyWhenNotPreviouslyRegistered() throws Exception {
final TestWorkHandler workHandler1 = createTestWorkHandler();
final DelayedEventHandler delayedEventHandler1 = createDelayedEventHandler();
final DelayedEventHandler delayedEventHandler2 = createDelayedEventHandler();
disruptor.handleEventsWith(delayedEventHandler1).and(disruptor.handleEventsWithWorkerPool(workHandler1)).then(delayedEventHandler2);
publishEvent();
publishEvent();
delayedEventHandler1.processEvent();
delayedEventHandler1.processEvent();
workHandler1.processEvent();
delayedEventHandler2.processEvent();
workHandler1.processEvent();
delayedEventHandler2.processEvent();
}
use of com.lmax.disruptor.dsl.stubs.TestWorkHandler in project disruptor by LMAX-Exchange.
the class DisruptorTest method createTestWorkHandler.
private TestWorkHandler createTestWorkHandler() {
final TestWorkHandler testWorkHandler = new TestWorkHandler();
testWorkHandlers.add(testWorkHandler);
return testWorkHandler;
}
use of com.lmax.disruptor.dsl.stubs.TestWorkHandler in project disruptor by LMAX-Exchange.
the class DisruptorTest method tearDown.
@After
public void tearDown() throws Exception {
for (DelayedEventHandler delayedEventHandler : delayedEventHandlers) {
delayedEventHandler.stopWaiting();
}
for (TestWorkHandler testWorkHandler : testWorkHandlers) {
testWorkHandler.stopWaiting();
}
disruptor.halt();
executor.joinAllThreads();
}
use of com.lmax.disruptor.dsl.stubs.TestWorkHandler in project disruptor by LMAX-Exchange.
the class DisruptorTest method shouldSupportUsingWorkerPoolAsDependency.
@Test
public void shouldSupportUsingWorkerPoolAsDependency() throws Exception {
final TestWorkHandler workHandler1 = createTestWorkHandler();
final TestWorkHandler workHandler2 = createTestWorkHandler();
final DelayedEventHandler delayedEventHandler = createDelayedEventHandler();
disruptor.handleEventsWithWorkerPool(workHandler1, workHandler2).then(delayedEventHandler);
publishEvent();
publishEvent();
assertThat(disruptor.getBarrierFor(delayedEventHandler).getCursor(), equalTo(-1L));
workHandler2.processEvent();
workHandler1.processEvent();
delayedEventHandler.processEvent();
}
Aggregations