/// <summary> /// Set up custom event processors to handle events from the ring buffer. The Disruptor will /// automatically start this processors when <see cref="Start"/> is called. /// /// This method can be used as the start of a chain. For example if the processor <code>A</code> must /// process events before handler<code>B</code>: /// <code>dw.HandleEventsWith(A).Then(B);</code> /// </summary> /// <param name="processors">processors the event processors that will process events</param> /// <returns>a <see cref="EventHandlerGroup{T}"/> that can be used to chain dependencies.</returns> public EventHandlerGroup <T> HandleEventsWith(params IEventProcessor[] processors) { foreach (var processor in processors) { _consumerRepository.Add(processor); } return(new EventHandlerGroup <T>(this, _consumerRepository, Util.GetSequencesFor(processors))); }
/// <summary> /// Create a new event handler group that combines the handlers in this group with <paramref name="processors"/>. /// </summary> /// <param name="processors">the processors to combine</param> /// <returns>a new ValueEventHandlerGroup combining the existing and new processors into a single dependency group</returns> public ValueEventHandlerGroup <T> And(params IEventProcessor[] processors) { foreach (var eventProcessor in processors) { _consumerRepository.Add(eventProcessor); } return(new ValueEventHandlerGroup <T>(_disruptor, _consumerRepository, processors.Select(p => p.Sequence).Concat(_sequences))); }
/// <summary> /// Set up custom event processors to handle events from the ring buffer. The disruptor will /// automatically start this processors when <see cref="Start"/> is called. /// /// This method can be used as the start of a chain. For example if the processor <code>A</code> must /// process events before handler<code>B</code>: /// <code>dw.HandleEventsWith(A).Then(B);</code> /// </summary> /// <param name="processors">processors the event processors that will process events</param> /// <returns>a <see cref="ValueEventHandlerGroup{T}"/> that can be used to chain dependencies.</returns> public ValueEventHandlerGroup <T> HandleEventsWith(params IEventProcessor[] processors) { foreach (var processor in processors) { _consumerRepository.Add(processor); } var sequences = new ISequence[processors.Length]; for (int i = 0; i < processors.Length; i++) { sequences[i] = processors[i].Sequence; } _ringBuffer.AddGatingSequences(sequences); return(new ValueEventHandlerGroup <T>(this, _consumerRepository, Util.GetSequencesFor(processors))); }
/// <summary> /// Create a new event handler group that combines the handlers in this group with <tt>processors</tt>. /// </summary> /// <param name="processors">the processors to combine.</param> /// <returns>a new EventHandlerGroup combining the existing and new processors into a single dependency group.</returns> public EventHandlerGroup <T> And(params IEventProcessor[] processors) { var combinedProcessors = processors.Select(e => e.Sequence).Concat(sequences).ToArray(); foreach (var eventProcessor in processors) { consumerRepository.Add(eventProcessor); } return(new EventHandlerGroup <T>(disruptor, consumerRepository, combinedProcessors)); }
/// <summary> /// Set up custom event processors to handle events from the ring buffer. The Disruptor will automatically start these processors when <see cref="StartAsync"/> is called. /// </summary> /// <param name="processors">the event processors that will process events.</param> /// <returns>a <see cref="EventHandlerGroup{T}"/> that can be used to chain dependencies.</returns> public EventHandlerGroup <T> HandleEventsWith(params IEventProcessor[] processors) { if (processors == null) { return(null); } foreach (var processor in processors) { _consumerRepository.Add(processor); } var sequences = new ISequence[processors.Length]; for (var i = 0; i < processors.Length; i++) { sequences[i] = processors[i].GetSequence(); } _ringBuffer.AddGatingSequences(sequences); return(new EventHandlerGroup <T>(this, _consumerRepository, SequenceGroupManager.GetSequencesFor(processors))); }