Exemple #1
0
 public override void Update(ILoadJob job, JobEngine engine)
 {
     if (job == null)
     {
         engine.SetState(EngineStatus.Wait);
         return;
     }
     //	キャンセル時
     if (job.IsCanceled || job.IsDisposed)
     {
         engine.Refresh();
         engine.SetState(EngineStatus.Wait);
         return;
     }
     job.Update();
     //	エラー
     if (job.IsError)
     {
         engine.SetState(EngineStatus.Error);
         return;
     }
     //	完了
     if (job.IsCompleted)
     {
         engine.SetState(EngineStatus.Complete);
         return;
     }
 }
Exemple #2
0
        public void Enqueue(ILoadJob request)
        {
            var engine = m_engineList[m_index];

            engine.Enqueue(request);
            m_index = (m_index + 1) % m_engineList.Length;
        }
Exemple #3
0
 /// <summary>
 ///
 /// </summary>
 public void Dispose()
 {
     m_onCompleted = null;
     m_job?.Dispose();
     m_job = null;
     ChipstarTracker.Remove(this);
 }
Exemple #4
0
 public void Update(ILoadJob job)
 {
     if (m_IsStop)
     {
         return;
     }
     DoUpdate(job);
 }
Exemple #5
0
 internal static void Log_AddJob(ILoadJob job)
 {
     if (!EnableLogDetail)
     {
         return;
     }
     Log(string.Format("Enqueue : {0}", job.ToString()));
 }
Exemple #6
0
 public override void Update(ILoadJob job, JobEngine engine)
 {
     if (!engine.MoveNext())
     {
         return;
     }
     engine.SetState(EngineStatus.Running);
 }
Exemple #7
0
 protected virtual bool MoveNext()
 {
     if (m_queue.Count <= 0)
     {
         return(false);
     }
     m_current = m_queue.Dequeue();
     return(true);
 }
Exemple #8
0
 public void Update(ILoadJob job)
 {
     foreach (var system in m_list)
     {
         system.Update(job);
         if (system.IsError)
         {
             IsError = true;
         }
     }
 }
Exemple #9
0
        /// <summary>
        /// キャンセル
        /// </summary>
        public void Cancel()
        {
            if (m_queue.Count > 0)
            {
                m_queue.Clear();
            }
            m_current.DisposeIfNotNull();
            m_current = null;

            //ステータスを待機に戻す
            SetState(EngineStatus.Wait);
        }
Exemple #10
0
        public ResultCode GetResultCode(ILoadJob job)
        {
            ResultCode code = default;

            foreach (var system in m_list)
            {
                if (system.IsError)
                {
                    code = system.GetResultCode(job);
                    break;
                }
            }
            return(code);
        }
Exemple #11
0
 protected override void DoUpdate(ILoadJob job)
 {
     m_trigger.Update(job);
     if (!m_trigger.IsError)
     {
         return;
     }
     m_currentCount++;
     m_trigger.Reset();
     if (IsError)
     {
         return;
     }
     job.Retry();
     Debug.Log("Retry : " + job.ToString() + ":::" + Time.realtimeSinceStartup);
 }
Exemple #12
0
        protected override void DoUpdate(ILoadJob job)
        {
            var current = Mathf.RoundToInt((job?.Progress ?? 0f) * 1000);
            var nowTime = Time.realtimeSinceStartup;

            if (IsNonProgress(current, m_oldProgress))
            {
                // 進捗変化がない時現在時と最後に記録された時間を比較
                var offset = nowTime - m_lastRunningTime;
                if (offset >= LimitTime)
                {
                    IsLimitOver = true;
                    return;
                }
            }
            else
            {
                // 可動時間を保存
                m_lastRunningTime = nowTime;
            }
            m_oldProgress = current;
        }
Exemple #13
0
        //=====================================
        //  関数
        //=====================================

        public LoadProcess(
            ILoadJob <T> job,
            Action <T> onCompleted,
            Action <ResultCode> onError = null
            )
        {
            m_onCompleted   = onCompleted;
            m_job           = job;
            m_job.OnSuccess = () =>
            {
                Content = m_job.Content;
                ChipstarUtils.OnceInvoke(ref m_onCompleted, Content);
                IsCompleted = true;
            };
            m_job.OnError = code =>
            {
                m_onCompleted = null;
                onError?.Invoke(code);
                IsError = true;
            };
            m_job.OnDisposed = () => this.DisposeIfNotNull();
            ChipstarTracker.Add(this);
        }
Exemple #14
0
 protected virtual ILoadJob <T> AddJob <T>(IJobEngine engine, ILoadJob <T> job)
 {
     engine.Enqueue(job);
     return(job);
 }
Exemple #15
0
 /// <summary>
 /// 追加
 /// </summary>
 public virtual void Enqueue(ILoadJob job)
 {
     ChipstarLog.Log_AddJob(job);
     m_queue.Enqueue(job);
 }
Exemple #16
0
 public override void Update(ILoadJob job, JobEngine engine)
 {
     engine.SetState(EngineStatus.Wait);
 }
Exemple #17
0
 public void Dispose()
 {
     m_current.DisposeIfNotNull();
     m_current = null;
     m_queue.Clear();
 }
Exemple #18
0
 private void Refresh()
 {
     //	今のリクエスト消す
     m_current.DisposeIfNotNull();
     m_current = null;
 }
Exemple #19
0
 protected abstract ResultCode DoGetResultCode(ILoadJob job);
Exemple #20
0
 public override void Begin(ILoadJob job, JobEngine engine)
 {
     job.Error();
     engine.Refresh();
 }
Exemple #21
0
 protected virtual void DoUpdate(ILoadJob job)
 {
 }
Exemple #22
0
 public virtual void End(ILoadJob job, JobEngine engine)
 {
 }
Exemple #23
0
 protected override ResultCode DoGetResultCode(ILoadJob job)
 {
     return(m_trigger.GetResultCode(job));
 }
Exemple #24
0
 /// <summary>
 /// 開始
 /// </summary>
 public virtual void Begin(ILoadJob job, JobEngine engine)
 {
 }
Exemple #25
0
 protected override ResultCode DoGetResultCode(ILoadJob job)
 {
     return(ChipstarResult.Timeout(job?.ToString() ?? string.Empty));
 }
Exemple #26
0
 public override void Begin(ILoadJob job, JobEngine engine)
 {
     job.Run();
 }
Exemple #27
0
 public virtual void Update(ILoadJob job, JobEngine engine)
 {
 }
Exemple #28
0
 public ResultCode GetResultCode(ILoadJob job)
 {
     return(DoGetResultCode(job));
 }