parent
6a5e259006
commit
6a7a6fde5c
|
@ -93,6 +93,9 @@ namespace Cysharp.Threading.Tasks.Linq
|
||||||
// return false instead of throw
|
// return false instead of throw
|
||||||
if (disposed || cancellationToken.IsCancellationRequested) return CompletedTasks.False;
|
if (disposed || cancellationToken.IsCancellationRequested) return CompletedTasks.False;
|
||||||
|
|
||||||
|
// reset value here.
|
||||||
|
this.elapsed = 0;
|
||||||
|
|
||||||
completionSource.Reset();
|
completionSource.Reset();
|
||||||
return new UniTask<bool>(this, completionSource.Version);
|
return new UniTask<bool>(this, completionSource.Version);
|
||||||
}
|
}
|
||||||
|
@ -121,7 +124,6 @@ namespace Cysharp.Threading.Tasks.Linq
|
||||||
if (elapsed >= dueTime)
|
if (elapsed >= dueTime)
|
||||||
{
|
{
|
||||||
dueTimePhase = false;
|
dueTimePhase = false;
|
||||||
elapsed = 0;
|
|
||||||
completionSource.TrySetResult(true);
|
completionSource.TrySetResult(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -135,7 +137,6 @@ namespace Cysharp.Threading.Tasks.Linq
|
||||||
|
|
||||||
if (elapsed >= period)
|
if (elapsed >= period)
|
||||||
{
|
{
|
||||||
elapsed = 0;
|
|
||||||
completionSource.TrySetResult(true);
|
completionSource.TrySetResult(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -196,6 +197,10 @@ namespace Cysharp.Threading.Tasks.Linq
|
||||||
// return false instead of throw
|
// return false instead of throw
|
||||||
if (disposed || cancellationToken.IsCancellationRequested) return CompletedTasks.False;
|
if (disposed || cancellationToken.IsCancellationRequested) return CompletedTasks.False;
|
||||||
|
|
||||||
|
|
||||||
|
// reset value here.
|
||||||
|
this.currentFrame = 0;
|
||||||
|
|
||||||
completionSource.Reset();
|
completionSource.Reset();
|
||||||
return new UniTask<bool>(this, completionSource.Version);
|
return new UniTask<bool>(this, completionSource.Version);
|
||||||
}
|
}
|
||||||
|
@ -220,11 +225,10 @@ namespace Cysharp.Threading.Tasks.Linq
|
||||||
|
|
||||||
if (dueTimePhase)
|
if (dueTimePhase)
|
||||||
{
|
{
|
||||||
if (currentFrame++ == dueTimeFrameCount)
|
if (currentFrame++ >= dueTimeFrameCount)
|
||||||
{
|
{
|
||||||
dueTimePhase = false;
|
dueTimePhase = false;
|
||||||
completionSource.TrySetResult(true);
|
completionSource.TrySetResult(true);
|
||||||
currentFrame = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -235,10 +239,9 @@ namespace Cysharp.Threading.Tasks.Linq
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (++currentFrame == periodFrameCount)
|
if (++currentFrame >= periodFrameCount)
|
||||||
{
|
{
|
||||||
completionSource.TrySetResult(true);
|
completionSource.TrySetResult(true);
|
||||||
currentFrame = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -145,11 +145,13 @@ public class SandboxMain : MonoBehaviour
|
||||||
|
|
||||||
//StartCoroutine(cor);
|
//StartCoroutine(cor);
|
||||||
|
|
||||||
|
// UniTaskAsyncEnumerable.EveryUpdate(PlayerLoopTiming.FixedUpdate)
|
||||||
|
|
||||||
// await UniTask.Yield(PlayerLoopTiming.EarlyUpdate);
|
|
||||||
|
await UniTask.Yield(PlayerLoopTiming.Update);
|
||||||
Debug.Log("Start:" + Time.frameCount);
|
Debug.Log("Start:" + Time.frameCount);
|
||||||
|
|
||||||
await UniTaskAsyncEnumerable.TimerFrame(3, 5, PlayerLoopTiming.LastPostLateUpdate).ForEachAsync(_ =>
|
await UniTaskAsyncEnumerable.TimerFrame(3, 5, PlayerLoopTiming.Update).ForEachAsync(_ =>
|
||||||
{
|
{
|
||||||
Debug.Log("Call:" + Time.frameCount);
|
Debug.Log("Call:" + Time.frameCount);
|
||||||
}, cancellationToken: this.GetCancellationTokenOnDestroy());
|
}, cancellationToken: this.GetCancellationTokenOnDestroy());
|
||||||
|
|
Loading…
Reference in New Issue