Merge pull request #204 from piti6/fix-defer
Accept calling DeferPromise.GetStatus multiple timesmaster
commit
478e2998a8
|
@ -341,10 +341,12 @@ namespace Cysharp.Threading.Tasks
|
||||||
public UniTaskStatus GetStatus(short token)
|
public UniTaskStatus GetStatus(short token)
|
||||||
{
|
{
|
||||||
var f = Interlocked.Exchange(ref factory, null);
|
var f = Interlocked.Exchange(ref factory, null);
|
||||||
if (f == null) throw new InvalidOperationException("Can't call twice.");
|
if (f != null)
|
||||||
|
{
|
||||||
task = f();
|
task = f();
|
||||||
awaiter = task.GetAwaiter();
|
awaiter = task.GetAwaiter();
|
||||||
|
}
|
||||||
|
|
||||||
return task.Status;
|
return task.Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -383,10 +385,12 @@ namespace Cysharp.Threading.Tasks
|
||||||
public UniTaskStatus GetStatus(short token)
|
public UniTaskStatus GetStatus(short token)
|
||||||
{
|
{
|
||||||
var f = Interlocked.Exchange(ref factory, null);
|
var f = Interlocked.Exchange(ref factory, null);
|
||||||
if (f == null) throw new InvalidOperationException("Can't call twice.");
|
if (f != null)
|
||||||
|
{
|
||||||
task = f();
|
task = f();
|
||||||
awaiter = task.GetAwaiter();
|
awaiter = task.GetAwaiter();
|
||||||
|
}
|
||||||
|
|
||||||
return task.Status;
|
return task.Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue