Exemple #1
0
        /// <summary>Executes the message loop.</summary>
        public void Start()
        {
            while (!_closed)
            {
                // Grab the next available message source, if any
                IEventSource <T> nextSource = _sources.Dequeue();
                if (null != nextSource)
                {
                    // Grab the next message from that source, if any
                    T message = nextSource.GetNext();
                    if (null != message)
                    {
                        // Add the source to the end of the queue again.
                        _sources.Enqueue(nextSource);

                        // Send the message. Note that this may block depending on the underlying EventHandler.
                        _output.OnNext(message);
                    }
                    else
                    {
                        // The message source has returned null as the next message. We drop the message source in that case.
                        LOGGER.Log(Level.Info, "Dropping message source {0} from the queue " + nextSource.ToString());
                    }
                }
            }
        }