public void ShouldMakeEntriesAvailableToFirstCustomProcessorsImmediately() { var countDownLatch = new CountdownEvent(2); var eventHandler = new CountDownEventHandler <TestEvent>(countDownLatch); _disruptor.HandleEventsWith(new EventProcessorFactory(_disruptor, eventHandler, 0)); EnsureTwoEventsProcessedAccordingToDependencies(countDownLatch); }
public void ShouldAllowEventHandlerWithSuperType() { var latch = new CountdownEvent(2); var objectHandler = new CountDownEventHandler <object>(latch); _disruptor.HandleEventsWith(objectHandler); EnsureTwoEventsProcessedAccordingToDependencies(latch); }
public void ShouldMakeEntriesAvailableToFirstHandlersImmediately() { var countDownLatch = new CountdownEvent(2); var eventHandler = new CountDownEventHandler <TestEvent>(countDownLatch); _disruptor.HandleEventsWith(CreateDelayedEventHandler(), eventHandler); EnsureTwoEventsProcessedAccordingToDependencies(countDownLatch); }
public void ShouldAllowChainingEventHandlersWithSuperType() { var latch = new CountdownEvent(2); var delayedEventHandler = CreateDelayedEventHandler(); var objectHandler = new CountDownEventHandler <object>(latch); _disruptor.HandleEventsWith(delayedEventHandler).Then(objectHandler); EnsureTwoEventsProcessedAccordingToDependencies(latch, delayedEventHandler); }
public void ShouldHonourDependenciesForCustomProcessors() { var countDownLatch = new CountdownEvent(2); var eventHandler = new CountDownEventHandler <TestEvent>(countDownLatch); var delayedEventHandler = CreateDelayedEventHandler(); _disruptor.HandleEventsWith(delayedEventHandler).Then(new EventProcessorFactory(_disruptor, eventHandler, 1)); EnsureTwoEventsProcessedAccordingToDependencies(countDownLatch, delayedEventHandler); }
public void ShouldWaitUntilAllFirstEventProcessorsProcessEventBeforeMakingItAvailableToDependentEventProcessors() { var eventHandler1 = CreateDelayedEventHandler(); var countDownLatch = new CountdownEvent(2); var eventHandler2 = new CountDownEventHandler <TestEvent>(countDownLatch); _disruptor.HandleEventsWith(eventHandler1).Then(eventHandler2); EnsureTwoEventsProcessedAccordingToDependencies(countDownLatch, eventHandler1); }
public void ShouldMakeEntriesAvailableToFirstCustomProcessorsImmediately() { var countDownLatch = new CountdownEvent(2); var eventHandler = new CountDownEventHandler <TestEvent>(countDownLatch); _disruptor.HandleEventsWith(new TestEventProcessorFactory <TestEvent>((ringBuffer, barrierSequences) => { Assert.AreEqual(0, barrierSequences.Length, "Should not have had any barrier sequences"); return(BatchEventProcessorFactory.Create(_disruptor.RingBuffer, ringBuffer.NewBarrier(barrierSequences), eventHandler)); })); EnsureTwoEventsProcessedAccordingToDependencies(countDownLatch); }
public void ShouldAllowSpecifyingSpecificEventProcessorsToWaitFor() { var handler1 = CreateDelayedEventHandler(); var handler2 = CreateDelayedEventHandler(); var countDownLatch = new CountdownEvent(2); var handlerWithBarrier = new CountDownEventHandler <TestEvent>(countDownLatch); _disruptor.HandleEventsWith(handler1, handler2); _disruptor.After(handler1, handler2).HandleEventsWith(handlerWithBarrier); EnsureTwoEventsProcessedAccordingToDependencies(countDownLatch, handler1, handler2); }
public void ShouldHonourDependenciesForCustomProcessors() { var countDownLatch = new CountdownEvent(2); var eventHandler = new CountDownEventHandler <TestEvent>(countDownLatch); var delayedEventHandler = CreateDelayedEventHandler(); _disruptor.HandleEventsWith(delayedEventHandler).Then(new TestEventProcessorFactory <TestEvent>((ringBuffer, barrierSequences) => { Assert.AreEqual(1, barrierSequences.Length, "Should have had a barrier sequence"); return(BatchEventProcessorFactory.Create(_disruptor.RingBuffer, ringBuffer.NewBarrier(barrierSequences), eventHandler)); })); EnsureTwoEventsProcessedAccordingToDependencies(countDownLatch, delayedEventHandler); }
public void ShouldSupportCustomProcessorsAsDependencies() { var ringBuffer = _disruptor.RingBuffer; var delayedEventHandler = CreateDelayedEventHandler(); var countDownLatch = new CountdownEvent(2); var handlerWithBarrier = new CountDownEventHandler <TestEvent>(countDownLatch); var processor = BatchEventProcessorFactory.Create(ringBuffer, ringBuffer.NewBarrier(), delayedEventHandler); _disruptor.HandleEventsWith(processor).Then(handlerWithBarrier); EnsureTwoEventsProcessedAccordingToDependencies(countDownLatch, delayedEventHandler); }
public void ShouldWaitOnAllProducersJoinedByAnd() { var handler1 = CreateDelayedEventHandler(); var handler2 = CreateDelayedEventHandler(); var countDownLatch = new CountdownEvent(2); var handlerWithBarrier = new CountDownEventHandler <TestEvent>(countDownLatch); _disruptor.HandleEventsWith(handler1); var handler2Group = _disruptor.HandleEventsWith(handler2); _disruptor.After(handler1).And(handler2Group).HandleEventsWith(handlerWithBarrier); EnsureTwoEventsProcessedAccordingToDependencies(countDownLatch, handler1, handler2); }
public void ShouldSupportCustomProcessorsAndHandlersAsDependencies() { var delayedEventHandler1 = CreateDelayedEventHandler(); var delayedEventHandler2 = CreateDelayedEventHandler(); _disruptor.HandleEventsWith(delayedEventHandler1); var ringBuffer = _disruptor.RingBuffer; var countDownLatch = new CountdownEvent(2); var handlerWithBarrier = new CountDownEventHandler <TestEvent>(countDownLatch); var sequenceBarrier = _disruptor.After(delayedEventHandler1).AsSequenceBarrier(); var processor = BatchEventProcessorFactory.Create(ringBuffer, sequenceBarrier, delayedEventHandler2); _disruptor.After(delayedEventHandler1).And(processor).HandleEventsWith(handlerWithBarrier); EnsureTwoEventsProcessedAccordingToDependencies(countDownLatch, delayedEventHandler1, delayedEventHandler2); }
public void ShouldSupportMultipleCustomProcessorsAndHandlersAsDependencies() { var ringBuffer = _disruptor.RingBuffer; var countDownLatch = new CountdownEvent(2); var handlerWithBarrier = new CountDownEventHandler <TestEvent>(countDownLatch); var delayedEventHandler1 = CreateDelayedEventHandler(); var processor1 = BatchEventProcessorFactory.Create(ringBuffer, ringBuffer.NewBarrier(), delayedEventHandler1); var delayedEventHandler2 = CreateDelayedEventHandler(); var processor2 = BatchEventProcessorFactory.Create(ringBuffer, ringBuffer.NewBarrier(), delayedEventHandler2); _disruptor.HandleEventsWith(processor1, processor2); _disruptor.After(processor1, processor2).HandleEventsWith(handlerWithBarrier); EnsureTwoEventsProcessedAccordingToDependencies(countDownLatch, delayedEventHandler1, delayedEventHandler2); Assert.That(_executor.GetExecutionCount(), Is.EqualTo(3)); }
public void ShouldSupportHandlersAsDependenciesToCustomProcessors() { var delayedEventHandler = CreateDelayedEventHandler(); _disruptor.HandleEventsWith(delayedEventHandler); var ringBuffer = _disruptor.RingBuffer; var countDownLatch = new CountdownEvent(2); var handlerWithBarrier = new CountDownEventHandler <TestEvent>(countDownLatch); var sequenceBarrier = _disruptor.After(delayedEventHandler).AsSequenceBarrier(); var processor = BatchEventProcessorFactory.Create(ringBuffer, sequenceBarrier, handlerWithBarrier); _disruptor.HandleEventsWith(processor); EnsureTwoEventsProcessedAccordingToDependencies(countDownLatch, delayedEventHandler); Assert.That(_executor.GetExecutionCount(), Is.EqualTo(2)); }