示例#1
0
        public void Loop()
        {
            long timestamp = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
            int  count     = m_timerNodeQueue.Count;

            for (int i = 0; i < count; i++)
            {
                SSTimerNode timerNode = null;
                if (m_timerNodeQueue.TryDequeue(out timerNode))
                {
                    if (timestamp >= timerNode.TimeoutTimestamp)
                    {
                        Message msg = new Message();
                        msg.Source      = 0;
                        msg.Destination = timerNode.Opaque;
                        msg.Method      = "";
                        msg.Data        = null;
                        msg.RPCSession  = timerNode.Session;
                        msg.Type        = MessageType.Timer;

                        ServiceContext service = ServiceSlots.GetInstance().Get(timerNode.Opaque);
                        service.Push(msg);
                    }
                    else
                    {
                        m_timerNodeQueue.Enqueue(timerNode);
                    }
                }
                else
                {
                    break;
                }
            }
        }
示例#2
0
 public void Add(SSTimerNode node)
 {
     m_timerNodeQueue.Enqueue(node);
 }