Ejemplo n.º 1
0
        /// <summary>
        /// Starts the event processors and returns the fully configured ring buffer.
        ///
        /// The ring buffer is set up to prevent overwriting any entry that is yet to
        /// be processed by the slowest event processor.
        ///
        /// This method must only be called once after all event processors have been added.
        /// </summary>
        /// <returns>the configured ring buffer</returns>
        public RingBuffer <T> Start()
        {
            _ringBuffer.AddGatingSequences(_consumerRepository.GetLastSequenceInChain(true));

            CheckOnlyStartedOnce();
            foreach (var consumerInfo in _consumerRepository)
            {
                consumerInfo.Start(_executor);
            }

            return(_ringBuffer);
        }
        /// <summary>
        /// <p>Starts the event processors and returns the fully configured ring buffer.</p>
        ///
        /// <p>The ring buffer is set up to prevent overwriting any entry that is yet to
        /// be processed by the slowest event processor.</p>
        ///
        /// <p>This method must only be called once after all event processors have been added.</p>
        /// </summary>
        /// <returns>the configured ring buffer.</returns>
        public RingBuffer <T> Start()
        {
            var gatingSequences = consumerRepository.GetLastSequenceInChain(true);

            ringBuffer.AddGatingSequences(gatingSequences);

            CheckOnlyStartedOnce();
            foreach (var consumerInfo in consumerRepository.AllConsumerInfos)
            {
                consumerInfo.Start(taskScheduler);
            }

            return(ringBuffer);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Confirms if all messages have been consumed by all event processors
        /// </summary>
        /// <returns></returns>
        private bool HasBacklog()
        {
            var cursor = _ringBuffer.Cursor;

            foreach (var sequence in _consumerRepository.GetLastSequenceInChain(false))
            {
                if (cursor > sequence.Value)
                {
                    return(true);
                }
            }
            return(false);
        }