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; } }
public void Enqueue(ILoadJob request) { var engine = m_engineList[m_index]; engine.Enqueue(request); m_index = (m_index + 1) % m_engineList.Length; }
/// <summary> /// /// </summary> public void Dispose() { m_onCompleted = null; m_job?.Dispose(); m_job = null; ChipstarTracker.Remove(this); }
public void Update(ILoadJob job) { if (m_IsStop) { return; } DoUpdate(job); }
internal static void Log_AddJob(ILoadJob job) { if (!EnableLogDetail) { return; } Log(string.Format("Enqueue : {0}", job.ToString())); }
public override void Update(ILoadJob job, JobEngine engine) { if (!engine.MoveNext()) { return; } engine.SetState(EngineStatus.Running); }
protected virtual bool MoveNext() { if (m_queue.Count <= 0) { return(false); } m_current = m_queue.Dequeue(); return(true); }
public void Update(ILoadJob job) { foreach (var system in m_list) { system.Update(job); if (system.IsError) { IsError = true; } } }
/// <summary> /// キャンセル /// </summary> public void Cancel() { if (m_queue.Count > 0) { m_queue.Clear(); } m_current.DisposeIfNotNull(); m_current = null; //ステータスを待機に戻す SetState(EngineStatus.Wait); }
public ResultCode GetResultCode(ILoadJob job) { ResultCode code = default; foreach (var system in m_list) { if (system.IsError) { code = system.GetResultCode(job); break; } } return(code); }
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); }
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; }
//===================================== // 関数 //===================================== 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); }
protected virtual ILoadJob <T> AddJob <T>(IJobEngine engine, ILoadJob <T> job) { engine.Enqueue(job); return(job); }
/// <summary> /// 追加 /// </summary> public virtual void Enqueue(ILoadJob job) { ChipstarLog.Log_AddJob(job); m_queue.Enqueue(job); }
public override void Update(ILoadJob job, JobEngine engine) { engine.SetState(EngineStatus.Wait); }
public void Dispose() { m_current.DisposeIfNotNull(); m_current = null; m_queue.Clear(); }
private void Refresh() { // 今のリクエスト消す m_current.DisposeIfNotNull(); m_current = null; }
protected abstract ResultCode DoGetResultCode(ILoadJob job);
public override void Begin(ILoadJob job, JobEngine engine) { job.Error(); engine.Refresh(); }
protected virtual void DoUpdate(ILoadJob job) { }
public virtual void End(ILoadJob job, JobEngine engine) { }
protected override ResultCode DoGetResultCode(ILoadJob job) { return(m_trigger.GetResultCode(job)); }
/// <summary> /// 開始 /// </summary> public virtual void Begin(ILoadJob job, JobEngine engine) { }
protected override ResultCode DoGetResultCode(ILoadJob job) { return(ChipstarResult.Timeout(job?.ToString() ?? string.Empty)); }
public override void Begin(ILoadJob job, JobEngine engine) { job.Run(); }
public virtual void Update(ILoadJob job, JobEngine engine) { }
public ResultCode GetResultCode(ILoadJob job) { return(DoGetResultCode(job)); }