Merge pull request #493 from Cysharp/hadashiA/monitor

Reduce the times of AwakeMonitor checking
pull/499/head
hadashiA 2023-09-08 17:18:50 +09:00 committed by GitHub
commit 06346b8a2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 7 deletions

View File

@ -32,13 +32,11 @@ namespace Cysharp.Threading.Tasks.Triggers
if (cancellationTokenSource == null) if (cancellationTokenSource == null)
{ {
cancellationTokenSource = new CancellationTokenSource(); cancellationTokenSource = new CancellationTokenSource();
if (!awakeCalled)
{
PlayerLoopHelper.AddAction(PlayerLoopTiming.Update, new AwakeMonitor(this));
}
} }
if (!awakeCalled)
{
PlayerLoopHelper.AddAction(PlayerLoopTiming.Update, new AwakeMonitor(this));
}
return cancellationTokenSource.Token; return cancellationTokenSource.Token;
} }
} }
@ -83,7 +81,7 @@ namespace Cysharp.Threading.Tasks.Triggers
public bool MoveNext() public bool MoveNext()
{ {
if (trigger.called) return false; if (trigger.called || trigger.awakeCalled) return false;
if (trigger == null) if (trigger == null)
{ {
trigger.OnDestroy(); trigger.OnDestroy();