/// <summary> /// Construct a <see cref="WorkProcessor{T}"/>. /// </summary> /// <param name="ringBuffer">to which events are published.</param> /// <param name="barrier">on which it is waiting.</param> /// <param name="workHandler">is the delegate to which events are dispatched.</param> /// <param name="exceptionHandler">to be called back when an error occurs.</param> /// <param name="workSequence">from which to claim the next event to be worked on. It should always be initialised <see cref="Sequence.InitialValue"/></param> public WorkProcessor( RingBuffer <T> ringBuffer, ISequenceBarrier barrier, IWorkHandler <T> workHandler, IExceptionHandler <T> exceptionHandler, ISequence workSequence) { _ringBuffer = ringBuffer; _barrier = barrier; _workHandler = workHandler; _exceptionHandler = exceptionHandler; _workSequence = workSequence; _sequence = new Sequence(); if (_workHandler is ITimeoutHandler timeoutHandler) { _timeoutHandler = timeoutHandler; } if (_workHandler is ILifecycleAware lifecycleAware) { _lifecycleAware = lifecycleAware; } if (_workHandler is IEventReleaseAware eventReleaseAware) { _eventReleaser = new EventReleaser(_sequence); eventReleaseAware.SetEventReleaser(_eventReleaser); } }
/// <summary> /// Construct a <see cref="WorkProcessor{T}"/>. /// </summary> /// <param name="ringBuffer">ringBuffer to which events are published.</param> /// <param name="sequenceBarrier">sequenceBarrier on which it is waiting.</param> /// <param name="workHandler">workHandler is the delegate to which events are dispatched.</param> /// <param name="exceptionHandler">exceptionHandler to be called back when an error occurs</param> /// <param name="workSequence">workSequence from which to claim the next event to be worked on. It should always be initialised /// as <see cref="Disruptor.Sequence.InitialCursorValue"/></param> public WorkProcessor(RingBuffer <T> ringBuffer, ISequenceBarrier sequenceBarrier, IWorkHandler <T> workHandler, IExceptionHandler <T> exceptionHandler, ISequence workSequence) { _ringBuffer = ringBuffer; _sequenceBarrier = sequenceBarrier; _workHandler = workHandler; _exceptionHandler = exceptionHandler; _workSequence = workSequence; _eventReleaser = new EventReleaser(this); (_workHandler as IEventReleaseAware)?.SetEventReleaser(_eventReleaser); _timeoutHandler = _workHandler as ITimeoutHandler; }
public void SetEventReleaser(IEventReleaser eventReleaser) { this.eventReleaser = eventReleaser; }
public void SetEventReleaser(IEventReleaser eventReleaser) { _eventReleaser = eventReleaser; }