Skip to content

Commit

Permalink
Tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
hadashiA committed Mar 28, 2024
1 parent caccccb commit 911c37d
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 84 deletions.
14 changes: 14 additions & 0 deletions src/UniTask/Assets/Plugins/UniTask/Runtime/UniTask.Delay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,9 @@ public void GetResult(short token)
finally
{
if (!(cancelImmediately && cancellationToken.IsCancellationRequested))
{
TryReturn();
}
}
}

Expand Down Expand Up @@ -361,7 +363,9 @@ public void GetResult(short token)
finally
{
if (!(cancelImmediately && cancellationToken.IsCancellationRequested))
{
TryReturn();
}
}
}

Expand Down Expand Up @@ -468,7 +472,9 @@ public void GetResult(short token)
finally
{
if (!(cancelImmediately && cancellationToken.IsCancellationRequested))
{
TryReturn();
}
}
}

Expand Down Expand Up @@ -595,7 +601,9 @@ public void GetResult(short token)
finally
{
if (!(cancelImmediately && cancellationToken.IsCancellationRequested))
{
TryReturn();
}
}
}

Expand Down Expand Up @@ -739,7 +747,9 @@ public void GetResult(short token)
finally
{
if (!(cancelImmediately && cancellationToken.IsCancellationRequested))
{
TryReturn();
}
}
}

Expand Down Expand Up @@ -865,7 +875,9 @@ public void GetResult(short token)
finally
{
if (!(cancelImmediately && cancellationToken.IsCancellationRequested))
{
TryReturn();
}
}
}

Expand Down Expand Up @@ -989,7 +1001,9 @@ public void GetResult(short token)
finally
{
if (!(cancelImmediately && cancellationToken.IsCancellationRequested))
{
TryReturn();
}
}
}

Expand Down
10 changes: 10 additions & 0 deletions src/UniTask/Assets/Plugins/UniTask/Runtime/UniTask.WaitUntil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ public void GetResult(short token)
finally
{
if (!(cancelImmediately && cancellationToken.IsCancellationRequested))
{
TryReturn();
}
}
}

Expand Down Expand Up @@ -218,7 +220,9 @@ public void GetResult(short token)
finally
{
if (!(cancelImmediately && cancellationToken.IsCancellationRequested))
{
TryReturn();
}
}
}

Expand Down Expand Up @@ -336,7 +340,9 @@ public void GetResult(short token)
finally
{
if (!(cancelImmediately && cancellationToken.IsCancellationRequested))
{
TryReturn();
}
}
}

Expand Down Expand Up @@ -450,7 +456,9 @@ public U GetResult(short token)
finally
{
if (!(cancelImmediately && cancellationToken.IsCancellationRequested))
{
TryReturn();
}
}
}

Expand Down Expand Up @@ -587,7 +595,9 @@ public U GetResult(short token)
finally
{
if (!(cancelImmediately && cancellationToken.IsCancellationRequested))
{
TryReturn();
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ public UnityEngine.Object[] GetResult(short token)
finally
{
if (!(cancelImmediately && cancellationToken.IsCancellationRequested))
{
TryReturn();
}
}
}

Expand Down Expand Up @@ -227,19 +229,17 @@ void Continuation(AsyncOperation _)
{
if (completed)
{
TryReturn();
return;
}

completed = true;
if (cancellationToken.IsCancellationRequested)
{
core.TrySetCanceled(cancellationToken);
}
else
{
completed = true;
if (cancellationToken.IsCancellationRequested)
{
core.TrySetCanceled(cancellationToken);
}
else
{
core.TrySetResult(asyncOperation.allAssets);
}
core.TrySetResult(asyncOperation.allAssets);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ public AsyncGPUReadbackRequest GetResult(short token)
finally
{
if (!(cancelImmediately && cancellationToken.IsCancellationRequested))
{
TryReturn();
}
}
}

Expand Down
103 changes: 49 additions & 54 deletions src/UniTask/Assets/Plugins/UniTask/Runtime/UnityAsyncExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,9 @@ public void GetResult(short token)
finally
{
if (!(cancelImmediately && cancellationToken.IsCancellationRequested))
{
TryReturn();
}
}
}

Expand Down Expand Up @@ -220,19 +222,16 @@ void Continuation(AsyncOperation _)
{
if (completed)
{
TryReturn();
return;
}
completed = true;
if (cancellationToken.IsCancellationRequested)
{
core.TrySetCanceled(cancellationToken);
}
else
{
completed = true;
if (cancellationToken.IsCancellationRequested)
{
core.TrySetCanceled(cancellationToken);
}
else
{
core.TrySetResult(AsyncUnit.Default);
}
core.TrySetResult(AsyncUnit.Default);
}
}
}
Expand Down Expand Up @@ -382,7 +381,9 @@ public UnityEngine.Object GetResult(short token)
finally
{
if (!(cancelImmediately && cancellationToken.IsCancellationRequested))
{
TryReturn();
}
}
}

Expand Down Expand Up @@ -451,19 +452,16 @@ void Continuation(AsyncOperation _)
{
if (completed)
{
TryReturn();
return;
}
completed = true;
if (cancellationToken.IsCancellationRequested)
{
core.TrySetCanceled(cancellationToken);
}
else
{
completed = true;
if (cancellationToken.IsCancellationRequested)
{
core.TrySetCanceled(cancellationToken);
}
else
{
core.TrySetResult(asyncOperation.asset);
}
core.TrySetResult(asyncOperation.asset);
}
}
}
Expand Down Expand Up @@ -614,7 +612,9 @@ public UnityEngine.Object GetResult(short token)
finally
{
if (!(cancelImmediately && cancellationToken.IsCancellationRequested))
{
TryReturn();
}
}
}

Expand Down Expand Up @@ -683,19 +683,16 @@ void Continuation(AsyncOperation _)
{
if (completed)
{
TryReturn();
return;
}
completed = true;
if (cancellationToken.IsCancellationRequested)
{
core.TrySetCanceled(cancellationToken);
}
else
{
completed = true;
if (cancellationToken.IsCancellationRequested)
{
core.TrySetCanceled(cancellationToken);
}
else
{
core.TrySetResult(asyncOperation.asset);
}
core.TrySetResult(asyncOperation.asset);
}
}
}
Expand Down Expand Up @@ -847,7 +844,9 @@ public AssetBundle GetResult(short token)
finally
{
if (!(cancelImmediately && cancellationToken.IsCancellationRequested))
{
TryReturn();
}
}
}

Expand Down Expand Up @@ -916,19 +915,16 @@ void Continuation(AsyncOperation _)
{
if (completed)
{
TryReturn();
return;
}
completed = true;
if (cancellationToken.IsCancellationRequested)
{
core.TrySetCanceled(cancellationToken);
}
else
{
completed = true;
if (cancellationToken.IsCancellationRequested)
{
core.TrySetCanceled(cancellationToken);
}
else
{
core.TrySetResult(asyncOperation.assetBundle);
}
core.TrySetResult(asyncOperation.assetBundle);
}
}
}
Expand Down Expand Up @@ -1096,7 +1092,9 @@ public UnityWebRequest GetResult(short token)
finally
{
if (!(cancelImmediately && cancellationToken.IsCancellationRequested))
{
TryReturn();
}
}
}

Expand Down Expand Up @@ -1173,23 +1171,20 @@ void Continuation(AsyncOperation _)
{
if (completed)
{
TryReturn();
return;
}
completed = true;
if (cancellationToken.IsCancellationRequested)
{
core.TrySetCanceled(cancellationToken);
}
else if (asyncOperation.webRequest.IsError())
{
core.TrySetException(new UnityWebRequestException(asyncOperation.webRequest));
}
else
{
completed = true;
if (cancellationToken.IsCancellationRequested)
{
core.TrySetCanceled(cancellationToken);
}
else if (asyncOperation.webRequest.IsError())
{
core.TrySetException(new UnityWebRequestException(asyncOperation.webRequest));
}
else
{
core.TrySetResult(asyncOperation.webRequest);
}
core.TrySetResult(asyncOperation.webRequest);
}
}
}
Expand Down
Loading

0 comments on commit 911c37d

Please sign in to comment.