Merge pull request #204 from piti6/fix-defer

Accept calling DeferPromise.GetStatus multiple times
master
Yoshifumi Kawai 2021-01-06 17:45:28 +09:00 committed by GitHub
commit 478e2998a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 6 deletions

View File

@ -341,10 +341,12 @@ namespace Cysharp.Threading.Tasks
public UniTaskStatus GetStatus(short token)
{
var f = Interlocked.Exchange(ref factory, null);
if (f == null) throw new InvalidOperationException("Can't call twice.");
if (f != null)
{
task = f();
awaiter = task.GetAwaiter();
}
task = f();
awaiter = task.GetAwaiter();
return task.Status;
}
@ -383,10 +385,12 @@ namespace Cysharp.Threading.Tasks
public UniTaskStatus GetStatus(short token)
{
var f = Interlocked.Exchange(ref factory, null);
if (f == null) throw new InvalidOperationException("Can't call twice.");
if (f != null)
{
task = f();
awaiter = task.GetAwaiter();
}
task = f();
awaiter = task.GetAwaiter();
return task.Status;
}