Exemple #1
0
        public void Update(float deltaTime)
        {
            // queues are swapped so that any new events added in response to an
            // event firing are processed in the next frame
            m_readIndex  = (m_readIndex + 1) & 1;
            m_writeIndex = (m_writeIndex + 1) & 1;

            if (ReadQueue.Count == 0)
            {
                return;
            }

            var count = 0;

            m_eventDispatchTimer.Restart();
            while (ReadQueue.Count > 0)
            {
                var evt = ReadQueue.First();
                ReadQueue.RemoveAt(0);
                TriggerEvent(evt);
                count++;
            }

            Log.Trace("Processed {0} events in {1:F4}s", count,
                      m_eventDispatchTimer.Elapsed.TotalSeconds);
        }
        // dispatches all pending messages in the read queue
        private void DispatchMessages()
        {
            var count = 0;

            while (ReadQueue.Count > 0)
            {
                var msg = ReadQueue.First();
                ReadQueue.RemoveAt(0);
                TriggerMessage(msg);
                count++;
            }

            Log.VerboseFmtIf(count > 0,
                             "{0} dispatched {1} messages", Parent.FullName, count);
        }