Beispiel #1
0
        private void ProcessWaitingTasks(float elapseSeconds, float realElapseSeconds)
        {
            LinkedListNode <T> current = m_WaitingTasks.First;

            while (current != null && FreeAgentCount > 0)
            {
                ITaskAgent <T> agent = m_FreeAgents.Pop();
                LinkedListNode <ITaskAgent <T> > agentNode = m_WorkingAgents.AddLast(agent);
                T task = current.Value;
                LinkedListNode <T> next   = current.Next;
                StartTaskStatus    status = agent.Start(task);
                if (status == StartTaskStatus.Done || status == StartTaskStatus.HasToWait || status == StartTaskStatus.UnknownError)
                {
                    agent.Reset();
                    m_FreeAgents.Push(agent);
                    m_WorkingAgents.Remove(agentNode);
                }

                if (status == StartTaskStatus.Done || status == StartTaskStatus.CanResume || status == StartTaskStatus.UnknownError)
                {
                    m_WaitingTasks.Remove(current);
                }

                if (status == StartTaskStatus.Done || status == StartTaskStatus.UnknownError)
                {
                    ReferencePool.Release(task);
                }

                current = next;
            }
        }
        /// <summary>
        /// 创建游戏框架模块。
        /// </summary>
        /// <param name="moduleType">要创建的游戏框架模块类型。</param>
        /// <returns>要创建的游戏框架模块。</returns>
        private static GXModule CreateModule(Type moduleType)
        {
            GXModule module = (GXModule)Activator.CreateInstance(moduleType);

            if (module == null)
            {
                throw new GXException(Utility.Text.Format("Can not create module '{0}'.", moduleType.FullName));
            }

            LinkedListNode <GXModule> current = s_GXModules.First;

            while (current != null)
            {
                if (module.Priority > current.Value.Priority)
                {
                    break;
                }

                current = current.Next;
            }

            if (current != null)
            {
                s_GXModules.AddBefore(current, module);
            }
            else
            {
                s_GXModules.AddLast(module);
            }

            return(module);
        }