public Subscription(ValuePublisher <T> publisher, IObserver <T> observer) { this.publisher = publisher; this.observer = observer; publisher.Add(this); if (publisher.hasValue) { observer.OnNext(publisher.value !); } }
public TwoToTwoWorkProcessorThroughputTest() { var sequenceBarrier = _ringBuffer.NewBarrier(); _handlers[0] = new ValueAdditionWorkHandler(); _handlers[1] = new ValueAdditionWorkHandler(); _workProcessors[0] = new WorkProcessor <ValueEvent>(_ringBuffer, sequenceBarrier, _handlers[0], new IgnoreExceptionHandler(), _workSequence); _workProcessors[1] = new WorkProcessor <ValueEvent>(_ringBuffer, sequenceBarrier, _handlers[1], new IgnoreExceptionHandler(), _workSequence); for (var i = 0; i < _numPublishers; i++) { _valuePublishers[i] = new ValuePublisher(_cyclicBarrier, _ringBuffer, _iterations); } _ringBuffer.AddGatingSequences(_workProcessors[0].Sequence, _workProcessors[1].Sequence); }
public TwoToTwoWorkProcessorThroughputTest() : base(Test_Disruptor, ITERATIONS) { sequenceBarrier = ringBuffer.NewBarrier(); handlers[0] = new ValueAdditionWorkHandler(); handlers[1] = new ValueAdditionWorkHandler(); workProcessors[0] = new WorkProcessor <ValueEvent>(ringBuffer, sequenceBarrier, handlers[0], new IgnoreExceptionHandler(), workSequence); workProcessors[1] = new WorkProcessor <ValueEvent>(ringBuffer, sequenceBarrier, handlers[1], new IgnoreExceptionHandler(), workSequence); for (int i = 0; i < NUM_PUBLISHERS; i++) { valuePublishers[i] = new ValuePublisher(cyclicBarrier, ringBuffer, ITERATIONS); } ringBuffer.AddGatingSequences(workProcessors[0].Sequence, workProcessors[1].Sequence); }