示例#1
0
        /// <summary>
        /// 生成任务。
        /// </summary>
        /// <typeparam name="T">任务的类型。</typeparam>
        /// <param name="priority">任务的优先级。</param>
        /// <returns>生成的指定类型的任务。</returns>
        public T GenerateTask <T>(int priority) where T : TaskBase, new()
        {
            T task = ReferencePool.Acquire <T>();

            task.Initialize(++m_Serial, priority);
            task.OnGenerate();

            LinkedListNode <TaskBase> current = m_Tasks.First;

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

                current = current.Next;
            }

            if (current != null)
            {
                m_Tasks.AddBefore(current, task);
            }
            else
            {
                m_Tasks.AddLast(task);
            }

            return(task);
        }
示例#2
0
            public void RecordDownloadedLength(int downloadedLength)
            {
                if (downloadedLength <= 0)
                {
                    return;
                }

                if (m_DownloadCounterNodes.Count > 0)
                {
                    DownloadCounterNode downloadCounterNode = m_DownloadCounterNodes.Last.Value;
                    if (downloadCounterNode.ElapseSeconds < m_UpdateInterval)
                    {
                        downloadCounterNode.AddDownloadedLength(downloadedLength);
                        return;
                    }
                }

                m_DownloadCounterNodes.AddLast(DownloadCounterNode.Create(downloadedLength));
            }
示例#3
0
 /// <summary>
 /// 往实体组增加实体。
 /// </summary>
 /// <param name="entity">要增加的实体。</param>
 public void AddEntity(IEntity entity)
 {
     m_Entities.AddLast(entity);
 }