UniTask/Assets/UniRx.Async/UniTask.WhenAny.Generated.cs

5130 lines
222 KiB
C#
Raw Normal View History

2020-04-21 12:36:23 +08:00
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
2019-05-19 23:14:47 +08:00
using System;
using System.Runtime.CompilerServices;
using System.Runtime.ExceptionServices;
using System.Threading;
2020-04-21 12:36:23 +08:00
using UniRx.Async.Internal;
2019-05-19 23:14:47 +08:00
namespace UniRx.Async
{
public partial struct UniTask
{
2020-04-21 12:36:23 +08:00
public static UniTask<(int winArgumentIndex, (bool hasResult, T1 result1), (bool hasResult, T2 result2))> WhenAny<T1, T2>(UniTask<T1> task1, UniTask<T2> task2)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
return new UniTask<(int winArgumentIndex, (bool hasResult, T1 result1), (bool hasResult, T2 result2))>(new WhenAnyPromise<T1, T2>(task1, task2), 0);
2019-05-19 23:14:47 +08:00
}
2020-04-21 12:36:23 +08:00
sealed class WhenAnyPromise<T1, T2> : IUniTaskSource<(int, (bool hasResult, T1 result1), (bool hasResult, T2 result2))>
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
int completedCount;
UniTaskCompletionSourceCore<(int, (bool hasResult, T1 result1), (bool hasResult, T2 result2))> core;
2019-05-19 23:14:47 +08:00
2020-04-21 12:36:23 +08:00
public WhenAnyPromise(UniTask<T1> task1, UniTask<T2> task2)
{
TaskTracker2.TrackActiveTask(this, 3);
2019-05-19 23:14:47 +08:00
2020-04-21 12:36:23 +08:00
this.completedCount = 0;
{
var awaiter = task1.GetAwaiter();
2019-05-19 23:14:47 +08:00
2020-04-21 12:36:23 +08:00
if (awaiter.IsCompleted)
{
TryInvokeContinuationT1(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2>, UniTask<T1>.Awaiter>)state)
{
TryInvokeContinuationT1(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task2.GetAwaiter();
2019-05-19 23:14:47 +08:00
2020-04-21 12:36:23 +08:00
if (awaiter.IsCompleted)
{
TryInvokeContinuationT2(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2>, UniTask<T2>.Awaiter>)state)
{
TryInvokeContinuationT2(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
}
static void TryInvokeContinuationT1(WhenAnyPromise<T1, T2> self, in UniTask<T1>.Awaiter awaiter)
{
T1 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((0, (true, result), (false, default)));
}
}
static void TryInvokeContinuationT2(WhenAnyPromise<T1, T2> self, in UniTask<T2>.Awaiter awaiter)
{
T2 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((1, (false, default), (true, result)));
}
}
public (int, (bool hasResult, T1 result1), (bool hasResult, T2 result2)) GetResult(short token)
{
TaskTracker2.RemoveTracking(this);
GC.SuppressFinalize(this);
return core.GetResult(token);
}
public UniTaskStatus GetStatus(short token)
{
return core.GetStatus(token);
}
public void OnCompleted(Action<object> continuation, object state, short token)
{
core.OnCompleted(continuation, state, token);
}
public UniTaskStatus UnsafeGetStatus()
{
return core.UnsafeGetStatus();
}
void IUniTaskSource.GetResult(short token)
{
GetResult(token);
}
~WhenAnyPromise()
{
core.Reset();
}
2019-05-19 23:14:47 +08:00
}
2020-04-21 12:36:23 +08:00
public static UniTask<(int winArgumentIndex, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3))> WhenAny<T1, T2, T3>(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
return new UniTask<(int winArgumentIndex, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3))>(new WhenAnyPromise<T1, T2, T3>(task1, task2, task3), 0);
2019-05-19 23:14:47 +08:00
}
2020-04-21 12:36:23 +08:00
sealed class WhenAnyPromise<T1, T2, T3> : IUniTaskSource<(int, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3))>
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
int completedCount;
UniTaskCompletionSourceCore<(int, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3))> core;
2019-05-19 23:14:47 +08:00
2020-04-21 12:36:23 +08:00
public WhenAnyPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
TaskTracker2.TrackActiveTask(this, 3);
this.completedCount = 0;
{
var awaiter = task1.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT1(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3>, UniTask<T1>.Awaiter>)state)
{
TryInvokeContinuationT1(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task2.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT2(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3>, UniTask<T2>.Awaiter>)state)
{
TryInvokeContinuationT2(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task3.GetAwaiter();
2019-05-19 23:14:47 +08:00
2020-04-21 12:36:23 +08:00
if (awaiter.IsCompleted)
{
TryInvokeContinuationT3(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3>, UniTask<T3>.Awaiter>)state)
{
TryInvokeContinuationT3(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
2019-05-19 23:14:47 +08:00
}
2020-04-21 12:36:23 +08:00
static void TryInvokeContinuationT1(WhenAnyPromise<T1, T2, T3> self, in UniTask<T1>.Awaiter awaiter)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
T1 result;
try
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((0, (true, result), (false, default), (false, default)));
2019-05-19 23:14:47 +08:00
}
}
2020-04-21 12:36:23 +08:00
static void TryInvokeContinuationT2(WhenAnyPromise<T1, T2, T3> self, in UniTask<T2>.Awaiter awaiter)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
T2 result;
2019-05-19 23:14:47 +08:00
try
{
2020-04-21 12:36:23 +08:00
result = awaiter.GetResult();
2019-05-19 23:14:47 +08:00
}
catch (Exception ex)
{
2020-04-21 12:36:23 +08:00
self.core.TrySetException(ex);
2019-05-19 23:14:47 +08:00
return;
}
2020-04-21 12:36:23 +08:00
if (Interlocked.Increment(ref self.completedCount) == 1)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
self.core.TrySetResult((1, (false, default), (true, result), (false, default)));
2019-05-19 23:14:47 +08:00
}
}
2020-04-21 12:36:23 +08:00
static void TryInvokeContinuationT3(WhenAnyPromise<T1, T2, T3> self, in UniTask<T3>.Awaiter awaiter)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
T3 result;
2019-05-19 23:14:47 +08:00
try
{
2020-04-21 12:36:23 +08:00
result = awaiter.GetResult();
2019-05-19 23:14:47 +08:00
}
catch (Exception ex)
{
2020-04-21 12:36:23 +08:00
self.core.TrySetException(ex);
2019-05-19 23:14:47 +08:00
return;
}
2020-04-21 12:36:23 +08:00
if (Interlocked.Increment(ref self.completedCount) == 1)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
self.core.TrySetResult((2, (false, default), (false, default), (true, result)));
2019-05-19 23:14:47 +08:00
}
}
2020-04-21 12:36:23 +08:00
public (int, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3)) GetResult(short token)
{
TaskTracker2.RemoveTracking(this);
GC.SuppressFinalize(this);
return core.GetResult(token);
}
public UniTaskStatus GetStatus(short token)
{
return core.GetStatus(token);
}
public void OnCompleted(Action<object> continuation, object state, short token)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
core.OnCompleted(continuation, state, token);
2019-05-19 23:14:47 +08:00
}
2020-04-21 12:36:23 +08:00
public UniTaskStatus UnsafeGetStatus()
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
return core.UnsafeGetStatus();
}
2019-05-19 23:14:47 +08:00
2020-04-21 12:36:23 +08:00
void IUniTaskSource.GetResult(short token)
{
GetResult(token);
}
~WhenAnyPromise()
{
core.Reset();
}
}
public static UniTask<(int winArgumentIndex, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4))> WhenAny<T1, T2, T3, T4>(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4)
{
return new UniTask<(int winArgumentIndex, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4))>(new WhenAnyPromise<T1, T2, T3, T4>(task1, task2, task3, task4), 0);
}
sealed class WhenAnyPromise<T1, T2, T3, T4> : IUniTaskSource<(int, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4))>
{
int completedCount;
UniTaskCompletionSourceCore<(int, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4))> core;
public WhenAnyPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4)
{
TaskTracker2.TrackActiveTask(this, 3);
2019-05-19 23:14:47 +08:00
2020-04-21 12:36:23 +08:00
this.completedCount = 0;
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
var awaiter = task1.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT1(this, awaiter);
}
else
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4>, UniTask<T1>.Awaiter>)state)
{
TryInvokeContinuationT1(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
2019-05-19 23:14:47 +08:00
}
}
{
2020-04-21 12:36:23 +08:00
var awaiter = task2.GetAwaiter();
if (awaiter.IsCompleted)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
TryInvokeContinuationT2(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4>, UniTask<T2>.Awaiter>)state)
{
TryInvokeContinuationT2(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
2019-05-19 23:14:47 +08:00
}
}
{
2020-04-21 12:36:23 +08:00
var awaiter = task3.GetAwaiter();
2019-05-19 23:14:47 +08:00
2020-04-21 12:36:23 +08:00
if (awaiter.IsCompleted)
{
TryInvokeContinuationT3(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4>, UniTask<T3>.Awaiter>)state)
{
TryInvokeContinuationT3(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
var awaiter = task4.GetAwaiter();
if (awaiter.IsCompleted)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
TryInvokeContinuationT4(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4>, UniTask<T4>.Awaiter>)state)
{
TryInvokeContinuationT4(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
2019-05-19 23:14:47 +08:00
}
}
}
2020-04-21 12:36:23 +08:00
static void TryInvokeContinuationT1(WhenAnyPromise<T1, T2, T3, T4> self, in UniTask<T1>.Awaiter awaiter)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
T1 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
2019-05-19 23:14:47 +08:00
2020-04-21 12:36:23 +08:00
if (Interlocked.Increment(ref self.completedCount) == 1)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
self.core.TrySetResult((0, (true, result), (false, default), (false, default), (false, default)));
2019-05-19 23:14:47 +08:00
}
}
2020-04-21 12:36:23 +08:00
static void TryInvokeContinuationT2(WhenAnyPromise<T1, T2, T3, T4> self, in UniTask<T2>.Awaiter awaiter)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
T2 result;
2019-05-19 23:14:47 +08:00
try
{
2020-04-21 12:36:23 +08:00
result = awaiter.GetResult();
2019-05-19 23:14:47 +08:00
}
catch (Exception ex)
{
2020-04-21 12:36:23 +08:00
self.core.TrySetException(ex);
2019-05-19 23:14:47 +08:00
return;
}
2020-04-21 12:36:23 +08:00
if (Interlocked.Increment(ref self.completedCount) == 1)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
self.core.TrySetResult((1, (false, default), (true, result), (false, default), (false, default)));
2019-05-19 23:14:47 +08:00
}
}
2020-04-21 12:36:23 +08:00
static void TryInvokeContinuationT3(WhenAnyPromise<T1, T2, T3, T4> self, in UniTask<T3>.Awaiter awaiter)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
T3 result;
2019-05-19 23:14:47 +08:00
try
{
2020-04-21 12:36:23 +08:00
result = awaiter.GetResult();
2019-05-19 23:14:47 +08:00
}
catch (Exception ex)
{
2020-04-21 12:36:23 +08:00
self.core.TrySetException(ex);
2019-05-19 23:14:47 +08:00
return;
}
2020-04-21 12:36:23 +08:00
if (Interlocked.Increment(ref self.completedCount) == 1)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
self.core.TrySetResult((2, (false, default), (false, default), (true, result), (false, default)));
2019-05-19 23:14:47 +08:00
}
}
2020-04-21 12:36:23 +08:00
static void TryInvokeContinuationT4(WhenAnyPromise<T1, T2, T3, T4> self, in UniTask<T4>.Awaiter awaiter)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
T4 result;
2019-05-19 23:14:47 +08:00
try
{
2020-04-21 12:36:23 +08:00
result = awaiter.GetResult();
2019-05-19 23:14:47 +08:00
}
catch (Exception ex)
{
2020-04-21 12:36:23 +08:00
self.core.TrySetException(ex);
2019-05-19 23:14:47 +08:00
return;
}
2020-04-21 12:36:23 +08:00
if (Interlocked.Increment(ref self.completedCount) == 1)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
self.core.TrySetResult((3, (false, default), (false, default), (false, default), (true, result)));
2019-05-19 23:14:47 +08:00
}
}
2020-04-21 12:36:23 +08:00
public (int, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4)) GetResult(short token)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
TaskTracker2.RemoveTracking(this);
GC.SuppressFinalize(this);
return core.GetResult(token);
2019-05-19 23:14:47 +08:00
}
2020-04-21 12:36:23 +08:00
public UniTaskStatus GetStatus(short token)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
return core.GetStatus(token);
}
2019-05-19 23:14:47 +08:00
2020-04-21 12:36:23 +08:00
public void OnCompleted(Action<object> continuation, object state, short token)
{
core.OnCompleted(continuation, state, token);
}
public UniTaskStatus UnsafeGetStatus()
{
return core.UnsafeGetStatus();
}
void IUniTaskSource.GetResult(short token)
{
GetResult(token);
}
~WhenAnyPromise()
{
core.Reset();
}
}
public static UniTask<(int winArgumentIndex, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4), (bool hasResult, T5 result5))> WhenAny<T1, T2, T3, T4, T5>(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5> task5)
{
return new UniTask<(int winArgumentIndex, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4), (bool hasResult, T5 result5))>(new WhenAnyPromise<T1, T2, T3, T4, T5>(task1, task2, task3, task4, task5), 0);
}
sealed class WhenAnyPromise<T1, T2, T3, T4, T5> : IUniTaskSource<(int, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4), (bool hasResult, T5 result5))>
{
int completedCount;
UniTaskCompletionSourceCore<(int, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4), (bool hasResult, T5 result5))> core;
2019-05-19 23:14:47 +08:00
2020-04-21 12:36:23 +08:00
public WhenAnyPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5> task5)
{
TaskTracker2.TrackActiveTask(this, 3);
this.completedCount = 0;
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
var awaiter = task1.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT1(this, awaiter);
}
else
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5>, UniTask<T1>.Awaiter>)state)
{
TryInvokeContinuationT1(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
2019-05-19 23:14:47 +08:00
}
}
{
2020-04-21 12:36:23 +08:00
var awaiter = task2.GetAwaiter();
if (awaiter.IsCompleted)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
TryInvokeContinuationT2(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5>, UniTask<T2>.Awaiter>)state)
{
TryInvokeContinuationT2(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
2019-05-19 23:14:47 +08:00
}
}
{
2020-04-21 12:36:23 +08:00
var awaiter = task3.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT3(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5>, UniTask<T3>.Awaiter>)state)
{
TryInvokeContinuationT3(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
2019-05-19 23:14:47 +08:00
}
2020-04-21 12:36:23 +08:00
{
var awaiter = task4.GetAwaiter();
2019-05-19 23:14:47 +08:00
2020-04-21 12:36:23 +08:00
if (awaiter.IsCompleted)
{
TryInvokeContinuationT4(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5>, UniTask<T4>.Awaiter>)state)
{
TryInvokeContinuationT4(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
var awaiter = task5.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT5(this, awaiter);
}
else
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
awaiter.SourceOnCompleted(state =>
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5>, UniTask<T5>.Awaiter>)state)
{
TryInvokeContinuationT5(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
2019-05-19 23:14:47 +08:00
}
}
}
2020-04-21 12:36:23 +08:00
static void TryInvokeContinuationT1(WhenAnyPromise<T1, T2, T3, T4, T5> self, in UniTask<T1>.Awaiter awaiter)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
T1 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
2019-05-19 23:14:47 +08:00
2020-04-21 12:36:23 +08:00
if (Interlocked.Increment(ref self.completedCount) == 1)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
self.core.TrySetResult((0, (true, result), (false, default), (false, default), (false, default), (false, default)));
2019-05-19 23:14:47 +08:00
}
}
2020-04-21 12:36:23 +08:00
static void TryInvokeContinuationT2(WhenAnyPromise<T1, T2, T3, T4, T5> self, in UniTask<T2>.Awaiter awaiter)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
T2 result;
2019-05-19 23:14:47 +08:00
try
{
2020-04-21 12:36:23 +08:00
result = awaiter.GetResult();
2019-05-19 23:14:47 +08:00
}
catch (Exception ex)
{
2020-04-21 12:36:23 +08:00
self.core.TrySetException(ex);
2019-05-19 23:14:47 +08:00
return;
}
2020-04-21 12:36:23 +08:00
if (Interlocked.Increment(ref self.completedCount) == 1)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
self.core.TrySetResult((1, (false, default), (true, result), (false, default), (false, default), (false, default)));
2019-05-19 23:14:47 +08:00
}
}
2020-04-21 12:36:23 +08:00
static void TryInvokeContinuationT3(WhenAnyPromise<T1, T2, T3, T4, T5> self, in UniTask<T3>.Awaiter awaiter)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
T3 result;
2019-05-19 23:14:47 +08:00
try
{
2020-04-21 12:36:23 +08:00
result = awaiter.GetResult();
2019-05-19 23:14:47 +08:00
}
catch (Exception ex)
{
2020-04-21 12:36:23 +08:00
self.core.TrySetException(ex);
2019-05-19 23:14:47 +08:00
return;
}
2020-04-21 12:36:23 +08:00
if (Interlocked.Increment(ref self.completedCount) == 1)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
self.core.TrySetResult((2, (false, default), (false, default), (true, result), (false, default), (false, default)));
2019-05-19 23:14:47 +08:00
}
}
2020-04-21 12:36:23 +08:00
static void TryInvokeContinuationT4(WhenAnyPromise<T1, T2, T3, T4, T5> self, in UniTask<T4>.Awaiter awaiter)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
T4 result;
2019-05-19 23:14:47 +08:00
try
{
2020-04-21 12:36:23 +08:00
result = awaiter.GetResult();
2019-05-19 23:14:47 +08:00
}
catch (Exception ex)
{
2020-04-21 12:36:23 +08:00
self.core.TrySetException(ex);
2019-05-19 23:14:47 +08:00
return;
}
2020-04-21 12:36:23 +08:00
if (Interlocked.Increment(ref self.completedCount) == 1)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
self.core.TrySetResult((3, (false, default), (false, default), (false, default), (true, result), (false, default)));
2019-05-19 23:14:47 +08:00
}
}
2020-04-21 12:36:23 +08:00
static void TryInvokeContinuationT5(WhenAnyPromise<T1, T2, T3, T4, T5> self, in UniTask<T5>.Awaiter awaiter)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
T5 result;
2019-05-19 23:14:47 +08:00
try
{
2020-04-21 12:36:23 +08:00
result = awaiter.GetResult();
2019-05-19 23:14:47 +08:00
}
catch (Exception ex)
{
2020-04-21 12:36:23 +08:00
self.core.TrySetException(ex);
2019-05-19 23:14:47 +08:00
return;
}
2020-04-21 12:36:23 +08:00
if (Interlocked.Increment(ref self.completedCount) == 1)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
self.core.TrySetResult((4, (false, default), (false, default), (false, default), (false, default), (true, result)));
2019-05-19 23:14:47 +08:00
}
}
2020-04-21 12:36:23 +08:00
public (int, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4), (bool hasResult, T5 result5)) GetResult(short token)
{
TaskTracker2.RemoveTracking(this);
GC.SuppressFinalize(this);
return core.GetResult(token);
}
public UniTaskStatus GetStatus(short token)
{
return core.GetStatus(token);
}
public void OnCompleted(Action<object> continuation, object state, short token)
{
core.OnCompleted(continuation, state, token);
}
public UniTaskStatus UnsafeGetStatus()
{
return core.UnsafeGetStatus();
}
void IUniTaskSource.GetResult(short token)
{
GetResult(token);
}
~WhenAnyPromise()
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
core.Reset();
2019-05-19 23:14:47 +08:00
}
2020-04-21 12:36:23 +08:00
}
public static UniTask<(int winArgumentIndex, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4), (bool hasResult, T5 result5), (bool hasResult, T6 result6))> WhenAny<T1, T2, T3, T4, T5, T6>(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5> task5, UniTask<T6> task6)
{
return new UniTask<(int winArgumentIndex, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4), (bool hasResult, T5 result5), (bool hasResult, T6 result6))>(new WhenAnyPromise<T1, T2, T3, T4, T5, T6>(task1, task2, task3, task4, task5, task6), 0);
}
sealed class WhenAnyPromise<T1, T2, T3, T4, T5, T6> : IUniTaskSource<(int, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4), (bool hasResult, T5 result5), (bool hasResult, T6 result6))>
{
int completedCount;
UniTaskCompletionSourceCore<(int, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4), (bool hasResult, T5 result5), (bool hasResult, T6 result6))> core;
2019-05-19 23:14:47 +08:00
2020-04-21 12:36:23 +08:00
public WhenAnyPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5> task5, UniTask<T6> task6)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
TaskTracker2.TrackActiveTask(this, 3);
2019-05-19 23:14:47 +08:00
2020-04-21 12:36:23 +08:00
this.completedCount = 0;
{
var awaiter = task1.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT1(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6>, UniTask<T1>.Awaiter>)state)
{
TryInvokeContinuationT1(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
var awaiter = task2.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT2(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6>, UniTask<T2>.Awaiter>)state)
{
TryInvokeContinuationT2(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task3.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT3(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6>, UniTask<T3>.Awaiter>)state)
{
TryInvokeContinuationT3(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task4.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT4(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6>, UniTask<T4>.Awaiter>)state)
{
TryInvokeContinuationT4(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task5.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT5(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6>, UniTask<T5>.Awaiter>)state)
{
TryInvokeContinuationT5(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task6.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT6(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6>, UniTask<T6>.Awaiter>)state)
{
TryInvokeContinuationT6(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
}
static void TryInvokeContinuationT1(WhenAnyPromise<T1, T2, T3, T4, T5, T6> self, in UniTask<T1>.Awaiter awaiter)
{
T1 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((0, (true, result), (false, default), (false, default), (false, default), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT2(WhenAnyPromise<T1, T2, T3, T4, T5, T6> self, in UniTask<T2>.Awaiter awaiter)
{
T2 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((1, (false, default), (true, result), (false, default), (false, default), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT3(WhenAnyPromise<T1, T2, T3, T4, T5, T6> self, in UniTask<T3>.Awaiter awaiter)
{
T3 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((2, (false, default), (false, default), (true, result), (false, default), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT4(WhenAnyPromise<T1, T2, T3, T4, T5, T6> self, in UniTask<T4>.Awaiter awaiter)
{
T4 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((3, (false, default), (false, default), (false, default), (true, result), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT5(WhenAnyPromise<T1, T2, T3, T4, T5, T6> self, in UniTask<T5>.Awaiter awaiter)
{
T5 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((4, (false, default), (false, default), (false, default), (false, default), (true, result), (false, default)));
}
}
static void TryInvokeContinuationT6(WhenAnyPromise<T1, T2, T3, T4, T5, T6> self, in UniTask<T6>.Awaiter awaiter)
{
T6 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((5, (false, default), (false, default), (false, default), (false, default), (false, default), (true, result)));
}
}
public (int, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4), (bool hasResult, T5 result5), (bool hasResult, T6 result6)) GetResult(short token)
{
TaskTracker2.RemoveTracking(this);
GC.SuppressFinalize(this);
return core.GetResult(token);
}
public UniTaskStatus GetStatus(short token)
{
return core.GetStatus(token);
}
public void OnCompleted(Action<object> continuation, object state, short token)
{
core.OnCompleted(continuation, state, token);
}
public UniTaskStatus UnsafeGetStatus()
{
return core.UnsafeGetStatus();
}
void IUniTaskSource.GetResult(short token)
{
GetResult(token);
}
~WhenAnyPromise()
{
core.Reset();
}
}
public static UniTask<(int winArgumentIndex, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4), (bool hasResult, T5 result5), (bool hasResult, T6 result6), (bool hasResult, T7 result7))> WhenAny<T1, T2, T3, T4, T5, T6, T7>(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5> task5, UniTask<T6> task6, UniTask<T7> task7)
{
return new UniTask<(int winArgumentIndex, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4), (bool hasResult, T5 result5), (bool hasResult, T6 result6), (bool hasResult, T7 result7))>(new WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7>(task1, task2, task3, task4, task5, task6, task7), 0);
}
sealed class WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7> : IUniTaskSource<(int, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4), (bool hasResult, T5 result5), (bool hasResult, T6 result6), (bool hasResult, T7 result7))>
{
int completedCount;
UniTaskCompletionSourceCore<(int, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4), (bool hasResult, T5 result5), (bool hasResult, T6 result6), (bool hasResult, T7 result7))> core;
public WhenAnyPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5> task5, UniTask<T6> task6, UniTask<T7> task7)
{
TaskTracker2.TrackActiveTask(this, 3);
this.completedCount = 0;
{
var awaiter = task1.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT1(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7>, UniTask<T1>.Awaiter>)state)
{
TryInvokeContinuationT1(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task2.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT2(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7>, UniTask<T2>.Awaiter>)state)
{
TryInvokeContinuationT2(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task3.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT3(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7>, UniTask<T3>.Awaiter>)state)
{
TryInvokeContinuationT3(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task4.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT4(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7>, UniTask<T4>.Awaiter>)state)
{
TryInvokeContinuationT4(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task5.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT5(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7>, UniTask<T5>.Awaiter>)state)
{
TryInvokeContinuationT5(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task6.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT6(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7>, UniTask<T6>.Awaiter>)state)
{
TryInvokeContinuationT6(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task7.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT7(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7>, UniTask<T7>.Awaiter>)state)
{
TryInvokeContinuationT7(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
}
static void TryInvokeContinuationT1(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7> self, in UniTask<T1>.Awaiter awaiter)
{
T1 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((0, (true, result), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT2(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7> self, in UniTask<T2>.Awaiter awaiter)
{
T2 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((1, (false, default), (true, result), (false, default), (false, default), (false, default), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT3(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7> self, in UniTask<T3>.Awaiter awaiter)
{
T3 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((2, (false, default), (false, default), (true, result), (false, default), (false, default), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT4(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7> self, in UniTask<T4>.Awaiter awaiter)
{
T4 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((3, (false, default), (false, default), (false, default), (true, result), (false, default), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT5(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7> self, in UniTask<T5>.Awaiter awaiter)
{
T5 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((4, (false, default), (false, default), (false, default), (false, default), (true, result), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT6(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7> self, in UniTask<T6>.Awaiter awaiter)
{
T6 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((5, (false, default), (false, default), (false, default), (false, default), (false, default), (true, result), (false, default)));
}
}
static void TryInvokeContinuationT7(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7> self, in UniTask<T7>.Awaiter awaiter)
{
T7 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((6, (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (true, result)));
}
}
public (int, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4), (bool hasResult, T5 result5), (bool hasResult, T6 result6), (bool hasResult, T7 result7)) GetResult(short token)
{
TaskTracker2.RemoveTracking(this);
GC.SuppressFinalize(this);
return core.GetResult(token);
}
public UniTaskStatus GetStatus(short token)
{
return core.GetStatus(token);
}
public void OnCompleted(Action<object> continuation, object state, short token)
{
core.OnCompleted(continuation, state, token);
}
public UniTaskStatus UnsafeGetStatus()
{
return core.UnsafeGetStatus();
}
void IUniTaskSource.GetResult(short token)
{
GetResult(token);
}
~WhenAnyPromise()
{
core.Reset();
}
}
public static UniTask<(int winArgumentIndex, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4), (bool hasResult, T5 result5), (bool hasResult, T6 result6), (bool hasResult, T7 result7), (bool hasResult, T8 result8))> WhenAny<T1, T2, T3, T4, T5, T6, T7, T8>(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5> task5, UniTask<T6> task6, UniTask<T7> task7, UniTask<T8> task8)
{
return new UniTask<(int winArgumentIndex, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4), (bool hasResult, T5 result5), (bool hasResult, T6 result6), (bool hasResult, T7 result7), (bool hasResult, T8 result8))>(new WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8>(task1, task2, task3, task4, task5, task6, task7, task8), 0);
}
sealed class WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8> : IUniTaskSource<(int, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4), (bool hasResult, T5 result5), (bool hasResult, T6 result6), (bool hasResult, T7 result7), (bool hasResult, T8 result8))>
{
int completedCount;
UniTaskCompletionSourceCore<(int, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4), (bool hasResult, T5 result5), (bool hasResult, T6 result6), (bool hasResult, T7 result7), (bool hasResult, T8 result8))> core;
public WhenAnyPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5> task5, UniTask<T6> task6, UniTask<T7> task7, UniTask<T8> task8)
{
TaskTracker2.TrackActiveTask(this, 3);
this.completedCount = 0;
{
var awaiter = task1.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT1(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8>, UniTask<T1>.Awaiter>)state)
{
TryInvokeContinuationT1(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task2.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT2(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8>, UniTask<T2>.Awaiter>)state)
{
TryInvokeContinuationT2(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task3.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT3(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8>, UniTask<T3>.Awaiter>)state)
{
TryInvokeContinuationT3(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task4.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT4(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8>, UniTask<T4>.Awaiter>)state)
{
TryInvokeContinuationT4(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task5.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT5(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8>, UniTask<T5>.Awaiter>)state)
{
TryInvokeContinuationT5(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task6.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT6(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8>, UniTask<T6>.Awaiter>)state)
{
TryInvokeContinuationT6(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task7.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT7(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8>, UniTask<T7>.Awaiter>)state)
{
TryInvokeContinuationT7(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task8.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT8(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8>, UniTask<T8>.Awaiter>)state)
{
TryInvokeContinuationT8(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
}
static void TryInvokeContinuationT1(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8> self, in UniTask<T1>.Awaiter awaiter)
{
T1 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((0, (true, result), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT2(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8> self, in UniTask<T2>.Awaiter awaiter)
{
T2 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((1, (false, default), (true, result), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT3(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8> self, in UniTask<T3>.Awaiter awaiter)
{
T3 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((2, (false, default), (false, default), (true, result), (false, default), (false, default), (false, default), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT4(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8> self, in UniTask<T4>.Awaiter awaiter)
{
T4 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((3, (false, default), (false, default), (false, default), (true, result), (false, default), (false, default), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT5(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8> self, in UniTask<T5>.Awaiter awaiter)
{
T5 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((4, (false, default), (false, default), (false, default), (false, default), (true, result), (false, default), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT6(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8> self, in UniTask<T6>.Awaiter awaiter)
{
T6 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((5, (false, default), (false, default), (false, default), (false, default), (false, default), (true, result), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT7(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8> self, in UniTask<T7>.Awaiter awaiter)
{
T7 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((6, (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (true, result), (false, default)));
}
}
static void TryInvokeContinuationT8(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8> self, in UniTask<T8>.Awaiter awaiter)
{
T8 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((7, (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (true, result)));
}
}
public (int, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4), (bool hasResult, T5 result5), (bool hasResult, T6 result6), (bool hasResult, T7 result7), (bool hasResult, T8 result8)) GetResult(short token)
{
TaskTracker2.RemoveTracking(this);
GC.SuppressFinalize(this);
return core.GetResult(token);
}
public UniTaskStatus GetStatus(short token)
{
return core.GetStatus(token);
}
public void OnCompleted(Action<object> continuation, object state, short token)
{
core.OnCompleted(continuation, state, token);
}
public UniTaskStatus UnsafeGetStatus()
{
return core.UnsafeGetStatus();
}
void IUniTaskSource.GetResult(short token)
{
GetResult(token);
}
~WhenAnyPromise()
{
core.Reset();
}
}
public static UniTask<(int winArgumentIndex, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4), (bool hasResult, T5 result5), (bool hasResult, T6 result6), (bool hasResult, T7 result7), (bool hasResult, T8 result8), (bool hasResult, T9 result9))> WhenAny<T1, T2, T3, T4, T5, T6, T7, T8, T9>(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5> task5, UniTask<T6> task6, UniTask<T7> task7, UniTask<T8> task8, UniTask<T9> task9)
{
return new UniTask<(int winArgumentIndex, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4), (bool hasResult, T5 result5), (bool hasResult, T6 result6), (bool hasResult, T7 result7), (bool hasResult, T8 result8), (bool hasResult, T9 result9))>(new WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9>(task1, task2, task3, task4, task5, task6, task7, task8, task9), 0);
}
sealed class WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9> : IUniTaskSource<(int, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4), (bool hasResult, T5 result5), (bool hasResult, T6 result6), (bool hasResult, T7 result7), (bool hasResult, T8 result8), (bool hasResult, T9 result9))>
{
int completedCount;
UniTaskCompletionSourceCore<(int, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4), (bool hasResult, T5 result5), (bool hasResult, T6 result6), (bool hasResult, T7 result7), (bool hasResult, T8 result8), (bool hasResult, T9 result9))> core;
public WhenAnyPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5> task5, UniTask<T6> task6, UniTask<T7> task7, UniTask<T8> task8, UniTask<T9> task9)
{
TaskTracker2.TrackActiveTask(this, 3);
this.completedCount = 0;
{
var awaiter = task1.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT1(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9>, UniTask<T1>.Awaiter>)state)
{
TryInvokeContinuationT1(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task2.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT2(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9>, UniTask<T2>.Awaiter>)state)
{
TryInvokeContinuationT2(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task3.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT3(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9>, UniTask<T3>.Awaiter>)state)
{
TryInvokeContinuationT3(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task4.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT4(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9>, UniTask<T4>.Awaiter>)state)
{
TryInvokeContinuationT4(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task5.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT5(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9>, UniTask<T5>.Awaiter>)state)
{
TryInvokeContinuationT5(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task6.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT6(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9>, UniTask<T6>.Awaiter>)state)
{
TryInvokeContinuationT6(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task7.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT7(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9>, UniTask<T7>.Awaiter>)state)
{
TryInvokeContinuationT7(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task8.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT8(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9>, UniTask<T8>.Awaiter>)state)
{
TryInvokeContinuationT8(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task9.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT9(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9>, UniTask<T9>.Awaiter>)state)
{
TryInvokeContinuationT9(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
}
static void TryInvokeContinuationT1(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9> self, in UniTask<T1>.Awaiter awaiter)
{
T1 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((0, (true, result), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT2(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9> self, in UniTask<T2>.Awaiter awaiter)
{
T2 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((1, (false, default), (true, result), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT3(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9> self, in UniTask<T3>.Awaiter awaiter)
{
T3 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((2, (false, default), (false, default), (true, result), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT4(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9> self, in UniTask<T4>.Awaiter awaiter)
{
T4 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((3, (false, default), (false, default), (false, default), (true, result), (false, default), (false, default), (false, default), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT5(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9> self, in UniTask<T5>.Awaiter awaiter)
{
T5 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((4, (false, default), (false, default), (false, default), (false, default), (true, result), (false, default), (false, default), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT6(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9> self, in UniTask<T6>.Awaiter awaiter)
{
T6 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((5, (false, default), (false, default), (false, default), (false, default), (false, default), (true, result), (false, default), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT7(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9> self, in UniTask<T7>.Awaiter awaiter)
{
T7 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((6, (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (true, result), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT8(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9> self, in UniTask<T8>.Awaiter awaiter)
{
T8 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((7, (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (true, result), (false, default)));
}
}
static void TryInvokeContinuationT9(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9> self, in UniTask<T9>.Awaiter awaiter)
{
T9 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((8, (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (true, result)));
}
}
public (int, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4), (bool hasResult, T5 result5), (bool hasResult, T6 result6), (bool hasResult, T7 result7), (bool hasResult, T8 result8), (bool hasResult, T9 result9)) GetResult(short token)
{
TaskTracker2.RemoveTracking(this);
GC.SuppressFinalize(this);
return core.GetResult(token);
}
public UniTaskStatus GetStatus(short token)
{
return core.GetStatus(token);
}
public void OnCompleted(Action<object> continuation, object state, short token)
{
core.OnCompleted(continuation, state, token);
}
public UniTaskStatus UnsafeGetStatus()
{
return core.UnsafeGetStatus();
}
void IUniTaskSource.GetResult(short token)
{
GetResult(token);
}
~WhenAnyPromise()
{
core.Reset();
}
}
public static UniTask<(int winArgumentIndex, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4), (bool hasResult, T5 result5), (bool hasResult, T6 result6), (bool hasResult, T7 result7), (bool hasResult, T8 result8), (bool hasResult, T9 result9), (bool hasResult, T10 result10))> WhenAny<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5> task5, UniTask<T6> task6, UniTask<T7> task7, UniTask<T8> task8, UniTask<T9> task9, UniTask<T10> task10)
{
return new UniTask<(int winArgumentIndex, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4), (bool hasResult, T5 result5), (bool hasResult, T6 result6), (bool hasResult, T7 result7), (bool hasResult, T8 result8), (bool hasResult, T9 result9), (bool hasResult, T10 result10))>(new WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(task1, task2, task3, task4, task5, task6, task7, task8, task9, task10), 0);
}
sealed class WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> : IUniTaskSource<(int, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4), (bool hasResult, T5 result5), (bool hasResult, T6 result6), (bool hasResult, T7 result7), (bool hasResult, T8 result8), (bool hasResult, T9 result9), (bool hasResult, T10 result10))>
{
int completedCount;
UniTaskCompletionSourceCore<(int, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4), (bool hasResult, T5 result5), (bool hasResult, T6 result6), (bool hasResult, T7 result7), (bool hasResult, T8 result8), (bool hasResult, T9 result9), (bool hasResult, T10 result10))> core;
public WhenAnyPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5> task5, UniTask<T6> task6, UniTask<T7> task7, UniTask<T8> task8, UniTask<T9> task9, UniTask<T10> task10)
{
TaskTracker2.TrackActiveTask(this, 3);
this.completedCount = 0;
{
var awaiter = task1.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT1(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>, UniTask<T1>.Awaiter>)state)
{
TryInvokeContinuationT1(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task2.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT2(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>, UniTask<T2>.Awaiter>)state)
{
TryInvokeContinuationT2(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task3.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT3(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>, UniTask<T3>.Awaiter>)state)
{
TryInvokeContinuationT3(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task4.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT4(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>, UniTask<T4>.Awaiter>)state)
{
TryInvokeContinuationT4(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task5.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT5(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>, UniTask<T5>.Awaiter>)state)
{
TryInvokeContinuationT5(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task6.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT6(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>, UniTask<T6>.Awaiter>)state)
{
TryInvokeContinuationT6(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task7.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT7(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>, UniTask<T7>.Awaiter>)state)
{
TryInvokeContinuationT7(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task8.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT8(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>, UniTask<T8>.Awaiter>)state)
{
TryInvokeContinuationT8(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task9.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT9(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>, UniTask<T9>.Awaiter>)state)
{
TryInvokeContinuationT9(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task10.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT10(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>, UniTask<T10>.Awaiter>)state)
{
TryInvokeContinuationT10(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
}
static void TryInvokeContinuationT1(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> self, in UniTask<T1>.Awaiter awaiter)
{
T1 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((0, (true, result), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT2(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> self, in UniTask<T2>.Awaiter awaiter)
{
T2 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((1, (false, default), (true, result), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT3(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> self, in UniTask<T3>.Awaiter awaiter)
{
T3 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((2, (false, default), (false, default), (true, result), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT4(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> self, in UniTask<T4>.Awaiter awaiter)
{
T4 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((3, (false, default), (false, default), (false, default), (true, result), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT5(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> self, in UniTask<T5>.Awaiter awaiter)
{
T5 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((4, (false, default), (false, default), (false, default), (false, default), (true, result), (false, default), (false, default), (false, default), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT6(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> self, in UniTask<T6>.Awaiter awaiter)
{
T6 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((5, (false, default), (false, default), (false, default), (false, default), (false, default), (true, result), (false, default), (false, default), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT7(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> self, in UniTask<T7>.Awaiter awaiter)
{
T7 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((6, (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (true, result), (false, default), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT8(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> self, in UniTask<T8>.Awaiter awaiter)
{
T8 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((7, (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (true, result), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT9(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> self, in UniTask<T9>.Awaiter awaiter)
{
T9 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((8, (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (true, result), (false, default)));
}
}
static void TryInvokeContinuationT10(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> self, in UniTask<T10>.Awaiter awaiter)
{
T10 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((9, (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (true, result)));
}
}
public (int, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4), (bool hasResult, T5 result5), (bool hasResult, T6 result6), (bool hasResult, T7 result7), (bool hasResult, T8 result8), (bool hasResult, T9 result9), (bool hasResult, T10 result10)) GetResult(short token)
{
TaskTracker2.RemoveTracking(this);
GC.SuppressFinalize(this);
return core.GetResult(token);
}
public UniTaskStatus GetStatus(short token)
{
return core.GetStatus(token);
}
public void OnCompleted(Action<object> continuation, object state, short token)
{
core.OnCompleted(continuation, state, token);
}
public UniTaskStatus UnsafeGetStatus()
{
return core.UnsafeGetStatus();
}
void IUniTaskSource.GetResult(short token)
{
GetResult(token);
}
~WhenAnyPromise()
{
core.Reset();
}
}
public static UniTask<(int winArgumentIndex, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4), (bool hasResult, T5 result5), (bool hasResult, T6 result6), (bool hasResult, T7 result7), (bool hasResult, T8 result8), (bool hasResult, T9 result9), (bool hasResult, T10 result10), (bool hasResult, T11 result11))> WhenAny<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5> task5, UniTask<T6> task6, UniTask<T7> task7, UniTask<T8> task8, UniTask<T9> task9, UniTask<T10> task10, UniTask<T11> task11)
{
return new UniTask<(int winArgumentIndex, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4), (bool hasResult, T5 result5), (bool hasResult, T6 result6), (bool hasResult, T7 result7), (bool hasResult, T8 result8), (bool hasResult, T9 result9), (bool hasResult, T10 result10), (bool hasResult, T11 result11))>(new WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(task1, task2, task3, task4, task5, task6, task7, task8, task9, task10, task11), 0);
}
sealed class WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> : IUniTaskSource<(int, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4), (bool hasResult, T5 result5), (bool hasResult, T6 result6), (bool hasResult, T7 result7), (bool hasResult, T8 result8), (bool hasResult, T9 result9), (bool hasResult, T10 result10), (bool hasResult, T11 result11))>
{
int completedCount;
UniTaskCompletionSourceCore<(int, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4), (bool hasResult, T5 result5), (bool hasResult, T6 result6), (bool hasResult, T7 result7), (bool hasResult, T8 result8), (bool hasResult, T9 result9), (bool hasResult, T10 result10), (bool hasResult, T11 result11))> core;
public WhenAnyPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5> task5, UniTask<T6> task6, UniTask<T7> task7, UniTask<T8> task8, UniTask<T9> task9, UniTask<T10> task10, UniTask<T11> task11)
{
TaskTracker2.TrackActiveTask(this, 3);
this.completedCount = 0;
{
var awaiter = task1.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT1(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>, UniTask<T1>.Awaiter>)state)
{
TryInvokeContinuationT1(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task2.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT2(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>, UniTask<T2>.Awaiter>)state)
{
TryInvokeContinuationT2(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task3.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT3(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>, UniTask<T3>.Awaiter>)state)
{
TryInvokeContinuationT3(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task4.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT4(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>, UniTask<T4>.Awaiter>)state)
{
TryInvokeContinuationT4(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task5.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT5(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>, UniTask<T5>.Awaiter>)state)
{
TryInvokeContinuationT5(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task6.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT6(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>, UniTask<T6>.Awaiter>)state)
{
TryInvokeContinuationT6(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task7.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT7(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>, UniTask<T7>.Awaiter>)state)
{
TryInvokeContinuationT7(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task8.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT8(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>, UniTask<T8>.Awaiter>)state)
{
TryInvokeContinuationT8(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task9.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT9(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>, UniTask<T9>.Awaiter>)state)
{
TryInvokeContinuationT9(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task10.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT10(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>, UniTask<T10>.Awaiter>)state)
{
TryInvokeContinuationT10(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task11.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT11(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>, UniTask<T11>.Awaiter>)state)
{
TryInvokeContinuationT11(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
}
static void TryInvokeContinuationT1(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> self, in UniTask<T1>.Awaiter awaiter)
{
T1 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((0, (true, result), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT2(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> self, in UniTask<T2>.Awaiter awaiter)
{
T2 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((1, (false, default), (true, result), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT3(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> self, in UniTask<T3>.Awaiter awaiter)
{
T3 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((2, (false, default), (false, default), (true, result), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT4(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> self, in UniTask<T4>.Awaiter awaiter)
{
T4 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((3, (false, default), (false, default), (false, default), (true, result), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT5(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> self, in UniTask<T5>.Awaiter awaiter)
{
T5 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((4, (false, default), (false, default), (false, default), (false, default), (true, result), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT6(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> self, in UniTask<T6>.Awaiter awaiter)
{
T6 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((5, (false, default), (false, default), (false, default), (false, default), (false, default), (true, result), (false, default), (false, default), (false, default), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT7(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> self, in UniTask<T7>.Awaiter awaiter)
{
T7 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((6, (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (true, result), (false, default), (false, default), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT8(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> self, in UniTask<T8>.Awaiter awaiter)
{
T8 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((7, (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (true, result), (false, default), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT9(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> self, in UniTask<T9>.Awaiter awaiter)
{
T9 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((8, (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (true, result), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT10(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> self, in UniTask<T10>.Awaiter awaiter)
{
T10 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((9, (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (true, result), (false, default)));
}
}
static void TryInvokeContinuationT11(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> self, in UniTask<T11>.Awaiter awaiter)
{
T11 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((10, (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (true, result)));
}
}
public (int, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4), (bool hasResult, T5 result5), (bool hasResult, T6 result6), (bool hasResult, T7 result7), (bool hasResult, T8 result8), (bool hasResult, T9 result9), (bool hasResult, T10 result10), (bool hasResult, T11 result11)) GetResult(short token)
{
TaskTracker2.RemoveTracking(this);
GC.SuppressFinalize(this);
return core.GetResult(token);
}
public UniTaskStatus GetStatus(short token)
{
return core.GetStatus(token);
}
public void OnCompleted(Action<object> continuation, object state, short token)
{
core.OnCompleted(continuation, state, token);
}
public UniTaskStatus UnsafeGetStatus()
{
return core.UnsafeGetStatus();
}
void IUniTaskSource.GetResult(short token)
{
GetResult(token);
}
~WhenAnyPromise()
{
core.Reset();
}
}
public static UniTask<(int winArgumentIndex, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4), (bool hasResult, T5 result5), (bool hasResult, T6 result6), (bool hasResult, T7 result7), (bool hasResult, T8 result8), (bool hasResult, T9 result9), (bool hasResult, T10 result10), (bool hasResult, T11 result11), (bool hasResult, T12 result12))> WhenAny<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5> task5, UniTask<T6> task6, UniTask<T7> task7, UniTask<T8> task8, UniTask<T9> task9, UniTask<T10> task10, UniTask<T11> task11, UniTask<T12> task12)
{
return new UniTask<(int winArgumentIndex, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4), (bool hasResult, T5 result5), (bool hasResult, T6 result6), (bool hasResult, T7 result7), (bool hasResult, T8 result8), (bool hasResult, T9 result9), (bool hasResult, T10 result10), (bool hasResult, T11 result11), (bool hasResult, T12 result12))>(new WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(task1, task2, task3, task4, task5, task6, task7, task8, task9, task10, task11, task12), 0);
}
sealed class WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> : IUniTaskSource<(int, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4), (bool hasResult, T5 result5), (bool hasResult, T6 result6), (bool hasResult, T7 result7), (bool hasResult, T8 result8), (bool hasResult, T9 result9), (bool hasResult, T10 result10), (bool hasResult, T11 result11), (bool hasResult, T12 result12))>
{
int completedCount;
UniTaskCompletionSourceCore<(int, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4), (bool hasResult, T5 result5), (bool hasResult, T6 result6), (bool hasResult, T7 result7), (bool hasResult, T8 result8), (bool hasResult, T9 result9), (bool hasResult, T10 result10), (bool hasResult, T11 result11), (bool hasResult, T12 result12))> core;
public WhenAnyPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5> task5, UniTask<T6> task6, UniTask<T7> task7, UniTask<T8> task8, UniTask<T9> task9, UniTask<T10> task10, UniTask<T11> task11, UniTask<T12> task12)
{
TaskTracker2.TrackActiveTask(this, 3);
this.completedCount = 0;
{
var awaiter = task1.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT1(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>, UniTask<T1>.Awaiter>)state)
{
TryInvokeContinuationT1(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task2.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT2(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>, UniTask<T2>.Awaiter>)state)
{
TryInvokeContinuationT2(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task3.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT3(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>, UniTask<T3>.Awaiter>)state)
{
TryInvokeContinuationT3(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task4.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT4(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>, UniTask<T4>.Awaiter>)state)
{
TryInvokeContinuationT4(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task5.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT5(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>, UniTask<T5>.Awaiter>)state)
{
TryInvokeContinuationT5(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task6.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT6(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>, UniTask<T6>.Awaiter>)state)
{
TryInvokeContinuationT6(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task7.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT7(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>, UniTask<T7>.Awaiter>)state)
{
TryInvokeContinuationT7(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task8.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT8(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>, UniTask<T8>.Awaiter>)state)
{
TryInvokeContinuationT8(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task9.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT9(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>, UniTask<T9>.Awaiter>)state)
{
TryInvokeContinuationT9(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task10.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT10(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>, UniTask<T10>.Awaiter>)state)
{
TryInvokeContinuationT10(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task11.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT11(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>, UniTask<T11>.Awaiter>)state)
{
TryInvokeContinuationT11(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task12.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT12(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>, UniTask<T12>.Awaiter>)state)
{
TryInvokeContinuationT12(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
}
static void TryInvokeContinuationT1(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> self, in UniTask<T1>.Awaiter awaiter)
{
T1 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((0, (true, result), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT2(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> self, in UniTask<T2>.Awaiter awaiter)
{
T2 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((1, (false, default), (true, result), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT3(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> self, in UniTask<T3>.Awaiter awaiter)
{
T3 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((2, (false, default), (false, default), (true, result), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT4(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> self, in UniTask<T4>.Awaiter awaiter)
{
T4 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((3, (false, default), (false, default), (false, default), (true, result), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT5(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> self, in UniTask<T5>.Awaiter awaiter)
{
T5 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((4, (false, default), (false, default), (false, default), (false, default), (true, result), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT6(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> self, in UniTask<T6>.Awaiter awaiter)
{
T6 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((5, (false, default), (false, default), (false, default), (false, default), (false, default), (true, result), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT7(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> self, in UniTask<T7>.Awaiter awaiter)
{
T7 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((6, (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (true, result), (false, default), (false, default), (false, default), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT8(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> self, in UniTask<T8>.Awaiter awaiter)
{
T8 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((7, (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (true, result), (false, default), (false, default), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT9(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> self, in UniTask<T9>.Awaiter awaiter)
{
T9 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((8, (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (true, result), (false, default), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT10(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> self, in UniTask<T10>.Awaiter awaiter)
{
T10 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((9, (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (true, result), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT11(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> self, in UniTask<T11>.Awaiter awaiter)
{
T11 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((10, (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (true, result), (false, default)));
}
}
static void TryInvokeContinuationT12(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> self, in UniTask<T12>.Awaiter awaiter)
{
T12 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((11, (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (true, result)));
}
}
public (int, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4), (bool hasResult, T5 result5), (bool hasResult, T6 result6), (bool hasResult, T7 result7), (bool hasResult, T8 result8), (bool hasResult, T9 result9), (bool hasResult, T10 result10), (bool hasResult, T11 result11), (bool hasResult, T12 result12)) GetResult(short token)
{
TaskTracker2.RemoveTracking(this);
GC.SuppressFinalize(this);
return core.GetResult(token);
}
public UniTaskStatus GetStatus(short token)
{
return core.GetStatus(token);
}
public void OnCompleted(Action<object> continuation, object state, short token)
{
core.OnCompleted(continuation, state, token);
}
public UniTaskStatus UnsafeGetStatus()
{
return core.UnsafeGetStatus();
}
void IUniTaskSource.GetResult(short token)
{
GetResult(token);
}
~WhenAnyPromise()
{
core.Reset();
}
}
public static UniTask<(int winArgumentIndex, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4), (bool hasResult, T5 result5), (bool hasResult, T6 result6), (bool hasResult, T7 result7), (bool hasResult, T8 result8), (bool hasResult, T9 result9), (bool hasResult, T10 result10), (bool hasResult, T11 result11), (bool hasResult, T12 result12), (bool hasResult, T13 result13))> WhenAny<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5> task5, UniTask<T6> task6, UniTask<T7> task7, UniTask<T8> task8, UniTask<T9> task9, UniTask<T10> task10, UniTask<T11> task11, UniTask<T12> task12, UniTask<T13> task13)
{
return new UniTask<(int winArgumentIndex, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4), (bool hasResult, T5 result5), (bool hasResult, T6 result6), (bool hasResult, T7 result7), (bool hasResult, T8 result8), (bool hasResult, T9 result9), (bool hasResult, T10 result10), (bool hasResult, T11 result11), (bool hasResult, T12 result12), (bool hasResult, T13 result13))>(new WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(task1, task2, task3, task4, task5, task6, task7, task8, task9, task10, task11, task12, task13), 0);
}
sealed class WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> : IUniTaskSource<(int, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4), (bool hasResult, T5 result5), (bool hasResult, T6 result6), (bool hasResult, T7 result7), (bool hasResult, T8 result8), (bool hasResult, T9 result9), (bool hasResult, T10 result10), (bool hasResult, T11 result11), (bool hasResult, T12 result12), (bool hasResult, T13 result13))>
{
int completedCount;
UniTaskCompletionSourceCore<(int, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4), (bool hasResult, T5 result5), (bool hasResult, T6 result6), (bool hasResult, T7 result7), (bool hasResult, T8 result8), (bool hasResult, T9 result9), (bool hasResult, T10 result10), (bool hasResult, T11 result11), (bool hasResult, T12 result12), (bool hasResult, T13 result13))> core;
public WhenAnyPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5> task5, UniTask<T6> task6, UniTask<T7> task7, UniTask<T8> task8, UniTask<T9> task9, UniTask<T10> task10, UniTask<T11> task11, UniTask<T12> task12, UniTask<T13> task13)
{
TaskTracker2.TrackActiveTask(this, 3);
this.completedCount = 0;
{
var awaiter = task1.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT1(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>, UniTask<T1>.Awaiter>)state)
{
TryInvokeContinuationT1(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task2.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT2(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>, UniTask<T2>.Awaiter>)state)
{
TryInvokeContinuationT2(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task3.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT3(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>, UniTask<T3>.Awaiter>)state)
{
TryInvokeContinuationT3(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task4.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT4(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>, UniTask<T4>.Awaiter>)state)
{
TryInvokeContinuationT4(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task5.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT5(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>, UniTask<T5>.Awaiter>)state)
{
TryInvokeContinuationT5(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task6.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT6(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>, UniTask<T6>.Awaiter>)state)
{
TryInvokeContinuationT6(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task7.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT7(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>, UniTask<T7>.Awaiter>)state)
{
TryInvokeContinuationT7(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task8.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT8(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>, UniTask<T8>.Awaiter>)state)
{
TryInvokeContinuationT8(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task9.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT9(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>, UniTask<T9>.Awaiter>)state)
{
TryInvokeContinuationT9(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task10.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT10(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>, UniTask<T10>.Awaiter>)state)
{
TryInvokeContinuationT10(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task11.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT11(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>, UniTask<T11>.Awaiter>)state)
{
TryInvokeContinuationT11(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task12.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT12(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>, UniTask<T12>.Awaiter>)state)
{
TryInvokeContinuationT12(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task13.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT13(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>, UniTask<T13>.Awaiter>)state)
{
TryInvokeContinuationT13(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
}
static void TryInvokeContinuationT1(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> self, in UniTask<T1>.Awaiter awaiter)
{
T1 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((0, (true, result), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT2(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> self, in UniTask<T2>.Awaiter awaiter)
{
T2 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((1, (false, default), (true, result), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT3(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> self, in UniTask<T3>.Awaiter awaiter)
{
T3 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((2, (false, default), (false, default), (true, result), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT4(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> self, in UniTask<T4>.Awaiter awaiter)
{
T4 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((3, (false, default), (false, default), (false, default), (true, result), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT5(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> self, in UniTask<T5>.Awaiter awaiter)
{
T5 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((4, (false, default), (false, default), (false, default), (false, default), (true, result), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT6(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> self, in UniTask<T6>.Awaiter awaiter)
{
T6 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((5, (false, default), (false, default), (false, default), (false, default), (false, default), (true, result), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT7(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> self, in UniTask<T7>.Awaiter awaiter)
{
T7 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((6, (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (true, result), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT8(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> self, in UniTask<T8>.Awaiter awaiter)
{
T8 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((7, (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (true, result), (false, default), (false, default), (false, default), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT9(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> self, in UniTask<T9>.Awaiter awaiter)
{
T9 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((8, (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (true, result), (false, default), (false, default), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT10(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> self, in UniTask<T10>.Awaiter awaiter)
{
T10 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((9, (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (true, result), (false, default), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT11(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> self, in UniTask<T11>.Awaiter awaiter)
{
T11 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((10, (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (true, result), (false, default), (false, default)));
}
}
static void TryInvokeContinuationT12(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> self, in UniTask<T12>.Awaiter awaiter)
{
T12 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((11, (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (true, result), (false, default)));
}
}
static void TryInvokeContinuationT13(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> self, in UniTask<T13>.Awaiter awaiter)
{
T13 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
if (Interlocked.Increment(ref self.completedCount) == 1)
{
self.core.TrySetResult((12, (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (true, result)));
}
}
public (int, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4), (bool hasResult, T5 result5), (bool hasResult, T6 result6), (bool hasResult, T7 result7), (bool hasResult, T8 result8), (bool hasResult, T9 result9), (bool hasResult, T10 result10), (bool hasResult, T11 result11), (bool hasResult, T12 result12), (bool hasResult, T13 result13)) GetResult(short token)
{
TaskTracker2.RemoveTracking(this);
GC.SuppressFinalize(this);
return core.GetResult(token);
}
public UniTaskStatus GetStatus(short token)
{
return core.GetStatus(token);
}
public void OnCompleted(Action<object> continuation, object state, short token)
{
core.OnCompleted(continuation, state, token);
}
public UniTaskStatus UnsafeGetStatus()
{
return core.UnsafeGetStatus();
}
void IUniTaskSource.GetResult(short token)
{
GetResult(token);
}
~WhenAnyPromise()
{
core.Reset();
}
}
public static UniTask<(int winArgumentIndex, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4), (bool hasResult, T5 result5), (bool hasResult, T6 result6), (bool hasResult, T7 result7), (bool hasResult, T8 result8), (bool hasResult, T9 result9), (bool hasResult, T10 result10), (bool hasResult, T11 result11), (bool hasResult, T12 result12), (bool hasResult, T13 result13), (bool hasResult, T14 result14))> WhenAny<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5> task5, UniTask<T6> task6, UniTask<T7> task7, UniTask<T8> task8, UniTask<T9> task9, UniTask<T10> task10, UniTask<T11> task11, UniTask<T12> task12, UniTask<T13> task13, UniTask<T14> task14)
{
return new UniTask<(int winArgumentIndex, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4), (bool hasResult, T5 result5), (bool hasResult, T6 result6), (bool hasResult, T7 result7), (bool hasResult, T8 result8), (bool hasResult, T9 result9), (bool hasResult, T10 result10), (bool hasResult, T11 result11), (bool hasResult, T12 result12), (bool hasResult, T13 result13), (bool hasResult, T14 result14))>(new WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(task1, task2, task3, task4, task5, task6, task7, task8, task9, task10, task11, task12, task13, task14), 0);
}
sealed class WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> : IUniTaskSource<(int, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4), (bool hasResult, T5 result5), (bool hasResult, T6 result6), (bool hasResult, T7 result7), (bool hasResult, T8 result8), (bool hasResult, T9 result9), (bool hasResult, T10 result10), (bool hasResult, T11 result11), (bool hasResult, T12 result12), (bool hasResult, T13 result13), (bool hasResult, T14 result14))>
{
int completedCount;
UniTaskCompletionSourceCore<(int, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4), (bool hasResult, T5 result5), (bool hasResult, T6 result6), (bool hasResult, T7 result7), (bool hasResult, T8 result8), (bool hasResult, T9 result9), (bool hasResult, T10 result10), (bool hasResult, T11 result11), (bool hasResult, T12 result12), (bool hasResult, T13 result13), (bool hasResult, T14 result14))> core;
public WhenAnyPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5> task5, UniTask<T6> task6, UniTask<T7> task7, UniTask<T8> task8, UniTask<T9> task9, UniTask<T10> task10, UniTask<T11> task11, UniTask<T12> task12, UniTask<T13> task13, UniTask<T14> task14)
{
TaskTracker2.TrackActiveTask(this, 3);
this.completedCount = 0;
{
var awaiter = task1.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT1(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>, UniTask<T1>.Awaiter>)state)
{
TryInvokeContinuationT1(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task2.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT2(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>, UniTask<T2>.Awaiter>)state)
{
TryInvokeContinuationT2(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task3.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT3(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>, UniTask<T3>.Awaiter>)state)
{
TryInvokeContinuationT3(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task4.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT4(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>, UniTask<T4>.Awaiter>)state)
{
TryInvokeContinuationT4(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task5.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT5(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>, UniTask<T5>.Awaiter>)state)
{
TryInvokeContinuationT5(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task6.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT6(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>, UniTask<T6>.Awaiter>)state)
{
TryInvokeContinuationT6(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task7.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT7(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>, UniTask<T7>.Awaiter>)state)
{
TryInvokeContinuationT7(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task8.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT8(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>, UniTask<T8>.Awaiter>)state)
{
TryInvokeContinuationT8(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task9.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT9(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>, UniTask<T9>.Awaiter>)state)
{
TryInvokeContinuationT9(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task10.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT10(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>, UniTask<T10>.Awaiter>)state)
{
TryInvokeContinuationT10(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task11.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT11(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>, UniTask<T11>.Awaiter>)state)
{
TryInvokeContinuationT11(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
2019-05-19 23:14:47 +08:00
}
{
2020-04-21 12:36:23 +08:00
var awaiter = task12.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT12(this, awaiter);
}
else
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>, UniTask<T12>.Awaiter>)state)
{
TryInvokeContinuationT12(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
2019-05-19 23:14:47 +08:00
}
}
{
2020-04-21 12:36:23 +08:00
var awaiter = task13.GetAwaiter();
if (awaiter.IsCompleted)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
TryInvokeContinuationT13(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>, UniTask<T13>.Awaiter>)state)
{
TryInvokeContinuationT13(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
2019-05-19 23:14:47 +08:00
}
}
{
2020-04-21 12:36:23 +08:00
var awaiter = task14.GetAwaiter();
2019-05-19 23:14:47 +08:00
2020-04-21 12:36:23 +08:00
if (awaiter.IsCompleted)
{
TryInvokeContinuationT14(this, awaiter);
}
else
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
awaiter.SourceOnCompleted(state =>
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>, UniTask<T14>.Awaiter>)state)
{
TryInvokeContinuationT14(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
2019-05-19 23:14:47 +08:00
}
}
}
2020-04-21 12:36:23 +08:00
static void TryInvokeContinuationT1(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> self, in UniTask<T1>.Awaiter awaiter)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
T1 result;
try
{
result = awaiter.GetResult();
}
catch (Exception ex)
{
self.core.TrySetException(ex);
return;
}
2019-05-19 23:14:47 +08:00
2020-04-21 12:36:23 +08:00
if (Interlocked.Increment(ref self.completedCount) == 1)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
self.core.TrySetResult((0, (true, result), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default)));
2019-05-19 23:14:47 +08:00
}
}
2020-04-21 12:36:23 +08:00
static void TryInvokeContinuationT2(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> self, in UniTask<T2>.Awaiter awaiter)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
T2 result;
2019-05-19 23:14:47 +08:00
try
{
2020-04-21 12:36:23 +08:00
result = awaiter.GetResult();
2019-05-19 23:14:47 +08:00
}
catch (Exception ex)
{
2020-04-21 12:36:23 +08:00
self.core.TrySetException(ex);
2019-05-19 23:14:47 +08:00
return;
}
2020-04-21 12:36:23 +08:00
if (Interlocked.Increment(ref self.completedCount) == 1)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
self.core.TrySetResult((1, (false, default), (true, result), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default)));
2019-05-19 23:14:47 +08:00
}
}
2020-04-21 12:36:23 +08:00
static void TryInvokeContinuationT3(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> self, in UniTask<T3>.Awaiter awaiter)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
T3 result;
2019-05-19 23:14:47 +08:00
try
{
2020-04-21 12:36:23 +08:00
result = awaiter.GetResult();
2019-05-19 23:14:47 +08:00
}
catch (Exception ex)
{
2020-04-21 12:36:23 +08:00
self.core.TrySetException(ex);
2019-05-19 23:14:47 +08:00
return;
}
2020-04-21 12:36:23 +08:00
if (Interlocked.Increment(ref self.completedCount) == 1)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
self.core.TrySetResult((2, (false, default), (false, default), (true, result), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default)));
2019-05-19 23:14:47 +08:00
}
}
2020-04-21 12:36:23 +08:00
static void TryInvokeContinuationT4(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> self, in UniTask<T4>.Awaiter awaiter)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
T4 result;
2019-05-19 23:14:47 +08:00
try
{
2020-04-21 12:36:23 +08:00
result = awaiter.GetResult();
2019-05-19 23:14:47 +08:00
}
catch (Exception ex)
{
2020-04-21 12:36:23 +08:00
self.core.TrySetException(ex);
2019-05-19 23:14:47 +08:00
return;
}
2020-04-21 12:36:23 +08:00
if (Interlocked.Increment(ref self.completedCount) == 1)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
self.core.TrySetResult((3, (false, default), (false, default), (false, default), (true, result), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default)));
2019-05-19 23:14:47 +08:00
}
}
2020-04-21 12:36:23 +08:00
static void TryInvokeContinuationT5(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> self, in UniTask<T5>.Awaiter awaiter)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
T5 result;
2019-05-19 23:14:47 +08:00
try
{
2020-04-21 12:36:23 +08:00
result = awaiter.GetResult();
2019-05-19 23:14:47 +08:00
}
catch (Exception ex)
{
2020-04-21 12:36:23 +08:00
self.core.TrySetException(ex);
2019-05-19 23:14:47 +08:00
return;
}
2020-04-21 12:36:23 +08:00
if (Interlocked.Increment(ref self.completedCount) == 1)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
self.core.TrySetResult((4, (false, default), (false, default), (false, default), (false, default), (true, result), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default)));
2019-05-19 23:14:47 +08:00
}
}
2020-04-21 12:36:23 +08:00
static void TryInvokeContinuationT6(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> self, in UniTask<T6>.Awaiter awaiter)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
T6 result;
2019-05-19 23:14:47 +08:00
try
{
2020-04-21 12:36:23 +08:00
result = awaiter.GetResult();
2019-05-19 23:14:47 +08:00
}
catch (Exception ex)
{
2020-04-21 12:36:23 +08:00
self.core.TrySetException(ex);
2019-05-19 23:14:47 +08:00
return;
}
2020-04-21 12:36:23 +08:00
if (Interlocked.Increment(ref self.completedCount) == 1)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
self.core.TrySetResult((5, (false, default), (false, default), (false, default), (false, default), (false, default), (true, result), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default)));
2019-05-19 23:14:47 +08:00
}
}
2020-04-21 12:36:23 +08:00
static void TryInvokeContinuationT7(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> self, in UniTask<T7>.Awaiter awaiter)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
T7 result;
try
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
result = awaiter.GetResult();
2019-05-19 23:14:47 +08:00
}
2020-04-21 12:36:23 +08:00
catch (Exception ex)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
self.core.TrySetException(ex);
return;
2019-05-19 23:14:47 +08:00
}
2020-04-21 12:36:23 +08:00
if (Interlocked.Increment(ref self.completedCount) == 1)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
self.core.TrySetResult((6, (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (true, result), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default)));
2019-05-19 23:14:47 +08:00
}
2020-04-21 12:36:23 +08:00
}
2019-05-19 23:14:47 +08:00
2020-04-21 12:36:23 +08:00
static void TryInvokeContinuationT8(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> self, in UniTask<T8>.Awaiter awaiter)
{
T8 result;
try
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
result = awaiter.GetResult();
2019-05-19 23:14:47 +08:00
}
2020-04-21 12:36:23 +08:00
catch (Exception ex)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
self.core.TrySetException(ex);
return;
2019-05-19 23:14:47 +08:00
}
2020-04-21 12:36:23 +08:00
if (Interlocked.Increment(ref self.completedCount) == 1)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
self.core.TrySetResult((7, (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (true, result), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default)));
2019-05-19 23:14:47 +08:00
}
}
2020-04-21 12:36:23 +08:00
static void TryInvokeContinuationT9(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> self, in UniTask<T9>.Awaiter awaiter)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
T9 result;
2019-05-19 23:14:47 +08:00
try
{
2020-04-21 12:36:23 +08:00
result = awaiter.GetResult();
2019-05-19 23:14:47 +08:00
}
catch (Exception ex)
{
2020-04-21 12:36:23 +08:00
self.core.TrySetException(ex);
2019-05-19 23:14:47 +08:00
return;
}
2020-04-21 12:36:23 +08:00
if (Interlocked.Increment(ref self.completedCount) == 1)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
self.core.TrySetResult((8, (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (true, result), (false, default), (false, default), (false, default), (false, default), (false, default)));
2019-05-19 23:14:47 +08:00
}
}
2020-04-21 12:36:23 +08:00
static void TryInvokeContinuationT10(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> self, in UniTask<T10>.Awaiter awaiter)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
T10 result;
2019-05-19 23:14:47 +08:00
try
{
2020-04-21 12:36:23 +08:00
result = awaiter.GetResult();
2019-05-19 23:14:47 +08:00
}
catch (Exception ex)
{
2020-04-21 12:36:23 +08:00
self.core.TrySetException(ex);
2019-05-19 23:14:47 +08:00
return;
}
2020-04-21 12:36:23 +08:00
if (Interlocked.Increment(ref self.completedCount) == 1)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
self.core.TrySetResult((9, (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (true, result), (false, default), (false, default), (false, default), (false, default)));
2019-05-19 23:14:47 +08:00
}
}
2020-04-21 12:36:23 +08:00
static void TryInvokeContinuationT11(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> self, in UniTask<T11>.Awaiter awaiter)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
T11 result;
2019-05-19 23:14:47 +08:00
try
{
2020-04-21 12:36:23 +08:00
result = awaiter.GetResult();
2019-05-19 23:14:47 +08:00
}
catch (Exception ex)
{
2020-04-21 12:36:23 +08:00
self.core.TrySetException(ex);
2019-05-19 23:14:47 +08:00
return;
}
2020-04-21 12:36:23 +08:00
if (Interlocked.Increment(ref self.completedCount) == 1)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
self.core.TrySetResult((10, (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (true, result), (false, default), (false, default), (false, default)));
2019-05-19 23:14:47 +08:00
}
}
2020-04-21 12:36:23 +08:00
static void TryInvokeContinuationT12(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> self, in UniTask<T12>.Awaiter awaiter)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
T12 result;
2019-05-19 23:14:47 +08:00
try
{
2020-04-21 12:36:23 +08:00
result = awaiter.GetResult();
2019-05-19 23:14:47 +08:00
}
catch (Exception ex)
{
2020-04-21 12:36:23 +08:00
self.core.TrySetException(ex);
2019-05-19 23:14:47 +08:00
return;
}
2020-04-21 12:36:23 +08:00
if (Interlocked.Increment(ref self.completedCount) == 1)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
self.core.TrySetResult((11, (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (true, result), (false, default), (false, default)));
2019-05-19 23:14:47 +08:00
}
}
2020-04-21 12:36:23 +08:00
static void TryInvokeContinuationT13(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> self, in UniTask<T13>.Awaiter awaiter)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
T13 result;
2019-05-19 23:14:47 +08:00
try
{
2020-04-21 12:36:23 +08:00
result = awaiter.GetResult();
2019-05-19 23:14:47 +08:00
}
catch (Exception ex)
{
2020-04-21 12:36:23 +08:00
self.core.TrySetException(ex);
2019-05-19 23:14:47 +08:00
return;
}
2020-04-21 12:36:23 +08:00
if (Interlocked.Increment(ref self.completedCount) == 1)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
self.core.TrySetResult((12, (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (true, result), (false, default)));
2019-05-19 23:14:47 +08:00
}
}
2020-04-21 12:36:23 +08:00
static void TryInvokeContinuationT14(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> self, in UniTask<T14>.Awaiter awaiter)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
T14 result;
2019-05-19 23:14:47 +08:00
try
{
2020-04-21 12:36:23 +08:00
result = awaiter.GetResult();
2019-05-19 23:14:47 +08:00
}
catch (Exception ex)
{
2020-04-21 12:36:23 +08:00
self.core.TrySetException(ex);
2019-05-19 23:14:47 +08:00
return;
}
2020-04-21 12:36:23 +08:00
if (Interlocked.Increment(ref self.completedCount) == 1)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
self.core.TrySetResult((13, (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (true, result)));
2019-05-19 23:14:47 +08:00
}
}
2020-04-21 12:36:23 +08:00
public (int, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4), (bool hasResult, T5 result5), (bool hasResult, T6 result6), (bool hasResult, T7 result7), (bool hasResult, T8 result8), (bool hasResult, T9 result9), (bool hasResult, T10 result10), (bool hasResult, T11 result11), (bool hasResult, T12 result12), (bool hasResult, T13 result13), (bool hasResult, T14 result14)) GetResult(short token)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
TaskTracker2.RemoveTracking(this);
GC.SuppressFinalize(this);
return core.GetResult(token);
2019-05-19 23:14:47 +08:00
}
2020-04-21 12:36:23 +08:00
public UniTaskStatus GetStatus(short token)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
return core.GetStatus(token);
}
2019-05-19 23:14:47 +08:00
2020-04-21 12:36:23 +08:00
public void OnCompleted(Action<object> continuation, object state, short token)
{
core.OnCompleted(continuation, state, token);
}
public UniTaskStatus UnsafeGetStatus()
{
return core.UnsafeGetStatus();
}
void IUniTaskSource.GetResult(short token)
{
GetResult(token);
}
~WhenAnyPromise()
{
core.Reset();
}
}
public static UniTask<(int winArgumentIndex, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4), (bool hasResult, T5 result5), (bool hasResult, T6 result6), (bool hasResult, T7 result7), (bool hasResult, T8 result8), (bool hasResult, T9 result9), (bool hasResult, T10 result10), (bool hasResult, T11 result11), (bool hasResult, T12 result12), (bool hasResult, T13 result13), (bool hasResult, T14 result14), (bool hasResult, T15 result15))> WhenAny<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5> task5, UniTask<T6> task6, UniTask<T7> task7, UniTask<T8> task8, UniTask<T9> task9, UniTask<T10> task10, UniTask<T11> task11, UniTask<T12> task12, UniTask<T13> task13, UniTask<T14> task14, UniTask<T15> task15)
{
return new UniTask<(int winArgumentIndex, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4), (bool hasResult, T5 result5), (bool hasResult, T6 result6), (bool hasResult, T7 result7), (bool hasResult, T8 result8), (bool hasResult, T9 result9), (bool hasResult, T10 result10), (bool hasResult, T11 result11), (bool hasResult, T12 result12), (bool hasResult, T13 result13), (bool hasResult, T14 result14), (bool hasResult, T15 result15))>(new WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(task1, task2, task3, task4, task5, task6, task7, task8, task9, task10, task11, task12, task13, task14, task15), 0);
}
sealed class WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> : IUniTaskSource<(int, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4), (bool hasResult, T5 result5), (bool hasResult, T6 result6), (bool hasResult, T7 result7), (bool hasResult, T8 result8), (bool hasResult, T9 result9), (bool hasResult, T10 result10), (bool hasResult, T11 result11), (bool hasResult, T12 result12), (bool hasResult, T13 result13), (bool hasResult, T14 result14), (bool hasResult, T15 result15))>
{
int completedCount;
UniTaskCompletionSourceCore<(int, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4), (bool hasResult, T5 result5), (bool hasResult, T6 result6), (bool hasResult, T7 result7), (bool hasResult, T8 result8), (bool hasResult, T9 result9), (bool hasResult, T10 result10), (bool hasResult, T11 result11), (bool hasResult, T12 result12), (bool hasResult, T13 result13), (bool hasResult, T14 result14), (bool hasResult, T15 result15))> core;
public WhenAnyPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5> task5, UniTask<T6> task6, UniTask<T7> task7, UniTask<T8> task8, UniTask<T9> task9, UniTask<T10> task10, UniTask<T11> task11, UniTask<T12> task12, UniTask<T13> task13, UniTask<T14> task14, UniTask<T15> task15)
{
TaskTracker2.TrackActiveTask(this, 3);
2019-05-19 23:14:47 +08:00
2020-04-21 12:36:23 +08:00
this.completedCount = 0;
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
var awaiter = task1.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT1(this, awaiter);
}
else
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>, UniTask<T1>.Awaiter>)state)
{
TryInvokeContinuationT1(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
2019-05-19 23:14:47 +08:00
}
}
{
2020-04-21 12:36:23 +08:00
var awaiter = task2.GetAwaiter();
if (awaiter.IsCompleted)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
TryInvokeContinuationT2(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>, UniTask<T2>.Awaiter>)state)
{
TryInvokeContinuationT2(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
2019-05-19 23:14:47 +08:00
}
}
{
2020-04-21 12:36:23 +08:00
var awaiter = task3.GetAwaiter();
2019-05-19 23:14:47 +08:00
2020-04-21 12:36:23 +08:00
if (awaiter.IsCompleted)
{
TryInvokeContinuationT3(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>, UniTask<T3>.Awaiter>)state)
{
TryInvokeContinuationT3(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
var awaiter = task4.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT4(this, awaiter);
}
else
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
awaiter.SourceOnCompleted(state =>
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>, UniTask<T4>.Awaiter>)state)
{
TryInvokeContinuationT4(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
2019-05-19 23:14:47 +08:00
}
}
2020-04-21 12:36:23 +08:00
{
var awaiter = task5.GetAwaiter();
2019-05-19 23:14:47 +08:00
2020-04-21 12:36:23 +08:00
if (awaiter.IsCompleted)
{
TryInvokeContinuationT5(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>, UniTask<T5>.Awaiter>)state)
{
TryInvokeContinuationT5(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task6.GetAwaiter();
2019-05-19 23:14:47 +08:00
2020-04-21 12:36:23 +08:00
if (awaiter.IsCompleted)
{
TryInvokeContinuationT6(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>, UniTask<T6>.Awaiter>)state)
{
TryInvokeContinuationT6(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task7.GetAwaiter();
2019-05-19 23:14:47 +08:00
2020-04-21 12:36:23 +08:00
if (awaiter.IsCompleted)
{
TryInvokeContinuationT7(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>, UniTask<T7>.Awaiter>)state)
{
TryInvokeContinuationT7(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task8.GetAwaiter();
2019-05-19 23:14:47 +08:00
2020-04-21 12:36:23 +08:00
if (awaiter.IsCompleted)
{
TryInvokeContinuationT8(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>, UniTask<T8>.Awaiter>)state)
{
TryInvokeContinuationT8(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
{
var awaiter = task9.GetAwaiter();
2019-05-19 23:14:47 +08:00
2020-04-21 12:36:23 +08:00
if (awaiter.IsCompleted)
{
TryInvokeContinuationT9(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>, UniTask<T9>.Awaiter>)state)
{
TryInvokeContinuationT9(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
var awaiter = task10.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT10(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>, UniTask<T10>.Awaiter>)state)
{
TryInvokeContinuationT10(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
2019-05-19 23:14:47 +08:00
}
2020-04-21 12:36:23 +08:00
{
var awaiter = task11.GetAwaiter();
2019-05-19 23:14:47 +08:00
2020-04-21 12:36:23 +08:00
if (awaiter.IsCompleted)
{
TryInvokeContinuationT11(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>, UniTask<T11>.Awaiter>)state)
{
TryInvokeContinuationT11(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
var awaiter = task12.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT12(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>, UniTask<T12>.Awaiter>)state)
{
TryInvokeContinuationT12(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
2019-05-19 23:14:47 +08:00
}
{
2020-04-21 12:36:23 +08:00
var awaiter = task13.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT13(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>, UniTask<T13>.Awaiter>)state)
{
TryInvokeContinuationT13(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
2019-05-19 23:14:47 +08:00
}
2020-04-21 12:36:23 +08:00
{
var awaiter = task14.GetAwaiter();
2019-05-19 23:14:47 +08:00
2020-04-21 12:36:23 +08:00
if (awaiter.IsCompleted)
{
TryInvokeContinuationT14(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>, UniTask<T14>.Awaiter>)state)
{
TryInvokeContinuationT14(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
}
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
var awaiter = task15.GetAwaiter();
if (awaiter.IsCompleted)
{
TryInvokeContinuationT15(this, awaiter);
}
else
{
awaiter.SourceOnCompleted(state =>
{
using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>, UniTask<T15>.Awaiter>)state)
{
TryInvokeContinuationT15(t.Item1, t.Item2);
}
}, StateTuple.Create(this, awaiter));
}
2019-05-19 23:14:47 +08:00
}
}
2020-04-21 12:36:23 +08:00
static void TryInvokeContinuationT1(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> self, in UniTask<T1>.Awaiter awaiter)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
T1 result;
2019-05-19 23:14:47 +08:00
try
{
2020-04-21 12:36:23 +08:00
result = awaiter.GetResult();
2019-05-19 23:14:47 +08:00
}
catch (Exception ex)
{
2020-04-21 12:36:23 +08:00
self.core.TrySetException(ex);
2019-05-19 23:14:47 +08:00
return;
}
2020-04-21 12:36:23 +08:00
if (Interlocked.Increment(ref self.completedCount) == 1)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
self.core.TrySetResult((0, (true, result), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default)));
2019-05-19 23:14:47 +08:00
}
}
2020-04-21 12:36:23 +08:00
static void TryInvokeContinuationT2(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> self, in UniTask<T2>.Awaiter awaiter)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
T2 result;
2019-05-19 23:14:47 +08:00
try
{
2020-04-21 12:36:23 +08:00
result = awaiter.GetResult();
2019-05-19 23:14:47 +08:00
}
catch (Exception ex)
{
2020-04-21 12:36:23 +08:00
self.core.TrySetException(ex);
2019-05-19 23:14:47 +08:00
return;
}
2020-04-21 12:36:23 +08:00
if (Interlocked.Increment(ref self.completedCount) == 1)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
self.core.TrySetResult((1, (false, default), (true, result), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default)));
2019-05-19 23:14:47 +08:00
}
}
2020-04-21 12:36:23 +08:00
static void TryInvokeContinuationT3(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> self, in UniTask<T3>.Awaiter awaiter)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
T3 result;
2019-05-19 23:14:47 +08:00
try
{
2020-04-21 12:36:23 +08:00
result = awaiter.GetResult();
2019-05-19 23:14:47 +08:00
}
catch (Exception ex)
{
2020-04-21 12:36:23 +08:00
self.core.TrySetException(ex);
2019-05-19 23:14:47 +08:00
return;
}
2020-04-21 12:36:23 +08:00
if (Interlocked.Increment(ref self.completedCount) == 1)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
self.core.TrySetResult((2, (false, default), (false, default), (true, result), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default)));
2019-05-19 23:14:47 +08:00
}
}
2020-04-21 12:36:23 +08:00
static void TryInvokeContinuationT4(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> self, in UniTask<T4>.Awaiter awaiter)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
T4 result;
2019-05-19 23:14:47 +08:00
try
{
2020-04-21 12:36:23 +08:00
result = awaiter.GetResult();
2019-05-19 23:14:47 +08:00
}
catch (Exception ex)
{
2020-04-21 12:36:23 +08:00
self.core.TrySetException(ex);
2019-05-19 23:14:47 +08:00
return;
}
2020-04-21 12:36:23 +08:00
if (Interlocked.Increment(ref self.completedCount) == 1)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
self.core.TrySetResult((3, (false, default), (false, default), (false, default), (true, result), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default)));
2019-05-19 23:14:47 +08:00
}
}
2020-04-21 12:36:23 +08:00
static void TryInvokeContinuationT5(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> self, in UniTask<T5>.Awaiter awaiter)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
T5 result;
2019-05-19 23:14:47 +08:00
try
{
2020-04-21 12:36:23 +08:00
result = awaiter.GetResult();
2019-05-19 23:14:47 +08:00
}
catch (Exception ex)
{
2020-04-21 12:36:23 +08:00
self.core.TrySetException(ex);
2019-05-19 23:14:47 +08:00
return;
}
2020-04-21 12:36:23 +08:00
if (Interlocked.Increment(ref self.completedCount) == 1)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
self.core.TrySetResult((4, (false, default), (false, default), (false, default), (false, default), (true, result), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default)));
2019-05-19 23:14:47 +08:00
}
}
2020-04-21 12:36:23 +08:00
static void TryInvokeContinuationT6(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> self, in UniTask<T6>.Awaiter awaiter)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
T6 result;
2019-05-19 23:14:47 +08:00
try
{
2020-04-21 12:36:23 +08:00
result = awaiter.GetResult();
2019-05-19 23:14:47 +08:00
}
catch (Exception ex)
{
2020-04-21 12:36:23 +08:00
self.core.TrySetException(ex);
2019-05-19 23:14:47 +08:00
return;
}
2020-04-21 12:36:23 +08:00
if (Interlocked.Increment(ref self.completedCount) == 1)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
self.core.TrySetResult((5, (false, default), (false, default), (false, default), (false, default), (false, default), (true, result), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default)));
2019-05-19 23:14:47 +08:00
}
}
2020-04-21 12:36:23 +08:00
static void TryInvokeContinuationT7(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> self, in UniTask<T7>.Awaiter awaiter)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
T7 result;
try
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
result = awaiter.GetResult();
2019-05-19 23:14:47 +08:00
}
2020-04-21 12:36:23 +08:00
catch (Exception ex)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
self.core.TrySetException(ex);
return;
2019-05-19 23:14:47 +08:00
}
2020-04-21 12:36:23 +08:00
if (Interlocked.Increment(ref self.completedCount) == 1)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
self.core.TrySetResult((6, (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (true, result), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default)));
2019-05-19 23:14:47 +08:00
}
}
2020-04-21 12:36:23 +08:00
static void TryInvokeContinuationT8(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> self, in UniTask<T8>.Awaiter awaiter)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
T8 result;
2019-05-19 23:14:47 +08:00
try
{
2020-04-21 12:36:23 +08:00
result = awaiter.GetResult();
2019-05-19 23:14:47 +08:00
}
catch (Exception ex)
{
2020-04-21 12:36:23 +08:00
self.core.TrySetException(ex);
2019-05-19 23:14:47 +08:00
return;
}
2020-04-21 12:36:23 +08:00
if (Interlocked.Increment(ref self.completedCount) == 1)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
self.core.TrySetResult((7, (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (true, result), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default)));
2019-05-19 23:14:47 +08:00
}
}
2020-04-21 12:36:23 +08:00
static void TryInvokeContinuationT9(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> self, in UniTask<T9>.Awaiter awaiter)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
T9 result;
2019-05-19 23:14:47 +08:00
try
{
2020-04-21 12:36:23 +08:00
result = awaiter.GetResult();
2019-05-19 23:14:47 +08:00
}
catch (Exception ex)
{
2020-04-21 12:36:23 +08:00
self.core.TrySetException(ex);
2019-05-19 23:14:47 +08:00
return;
}
2020-04-21 12:36:23 +08:00
if (Interlocked.Increment(ref self.completedCount) == 1)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
self.core.TrySetResult((8, (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (true, result), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default)));
2019-05-19 23:14:47 +08:00
}
}
2020-04-21 12:36:23 +08:00
static void TryInvokeContinuationT10(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> self, in UniTask<T10>.Awaiter awaiter)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
T10 result;
2019-05-19 23:14:47 +08:00
try
{
2020-04-21 12:36:23 +08:00
result = awaiter.GetResult();
2019-05-19 23:14:47 +08:00
}
catch (Exception ex)
{
2020-04-21 12:36:23 +08:00
self.core.TrySetException(ex);
2019-05-19 23:14:47 +08:00
return;
}
2020-04-21 12:36:23 +08:00
if (Interlocked.Increment(ref self.completedCount) == 1)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
self.core.TrySetResult((9, (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (true, result), (false, default), (false, default), (false, default), (false, default), (false, default)));
2019-05-19 23:14:47 +08:00
}
}
2020-04-21 12:36:23 +08:00
static void TryInvokeContinuationT11(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> self, in UniTask<T11>.Awaiter awaiter)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
T11 result;
2019-05-19 23:14:47 +08:00
try
{
2020-04-21 12:36:23 +08:00
result = awaiter.GetResult();
2019-05-19 23:14:47 +08:00
}
catch (Exception ex)
{
2020-04-21 12:36:23 +08:00
self.core.TrySetException(ex);
2019-05-19 23:14:47 +08:00
return;
}
2020-04-21 12:36:23 +08:00
if (Interlocked.Increment(ref self.completedCount) == 1)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
self.core.TrySetResult((10, (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (true, result), (false, default), (false, default), (false, default), (false, default)));
2019-05-19 23:14:47 +08:00
}
}
2020-04-21 12:36:23 +08:00
static void TryInvokeContinuationT12(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> self, in UniTask<T12>.Awaiter awaiter)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
T12 result;
2019-05-19 23:14:47 +08:00
try
{
2020-04-21 12:36:23 +08:00
result = awaiter.GetResult();
2019-05-19 23:14:47 +08:00
}
catch (Exception ex)
{
2020-04-21 12:36:23 +08:00
self.core.TrySetException(ex);
2019-05-19 23:14:47 +08:00
return;
}
2020-04-21 12:36:23 +08:00
if (Interlocked.Increment(ref self.completedCount) == 1)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
self.core.TrySetResult((11, (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (true, result), (false, default), (false, default), (false, default)));
2019-05-19 23:14:47 +08:00
}
}
2020-04-21 12:36:23 +08:00
static void TryInvokeContinuationT13(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> self, in UniTask<T13>.Awaiter awaiter)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
T13 result;
2019-05-19 23:14:47 +08:00
try
{
2020-04-21 12:36:23 +08:00
result = awaiter.GetResult();
2019-05-19 23:14:47 +08:00
}
catch (Exception ex)
{
2020-04-21 12:36:23 +08:00
self.core.TrySetException(ex);
2019-05-19 23:14:47 +08:00
return;
}
2020-04-21 12:36:23 +08:00
if (Interlocked.Increment(ref self.completedCount) == 1)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
self.core.TrySetResult((12, (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (true, result), (false, default), (false, default)));
2019-05-19 23:14:47 +08:00
}
}
2020-04-21 12:36:23 +08:00
static void TryInvokeContinuationT14(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> self, in UniTask<T14>.Awaiter awaiter)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
T14 result;
2019-05-19 23:14:47 +08:00
try
{
2020-04-21 12:36:23 +08:00
result = awaiter.GetResult();
2019-05-19 23:14:47 +08:00
}
catch (Exception ex)
{
2020-04-21 12:36:23 +08:00
self.core.TrySetException(ex);
2019-05-19 23:14:47 +08:00
return;
}
2020-04-21 12:36:23 +08:00
if (Interlocked.Increment(ref self.completedCount) == 1)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
self.core.TrySetResult((13, (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (true, result), (false, default)));
2019-05-19 23:14:47 +08:00
}
}
2020-04-21 12:36:23 +08:00
static void TryInvokeContinuationT15(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> self, in UniTask<T15>.Awaiter awaiter)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
T15 result;
2019-05-19 23:14:47 +08:00
try
{
2020-04-21 12:36:23 +08:00
result = awaiter.GetResult();
2019-05-19 23:14:47 +08:00
}
catch (Exception ex)
{
2020-04-21 12:36:23 +08:00
self.core.TrySetException(ex);
2019-05-19 23:14:47 +08:00
return;
}
2020-04-21 12:36:23 +08:00
if (Interlocked.Increment(ref self.completedCount) == 1)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
self.core.TrySetResult((14, (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (false, default), (true, result)));
2019-05-19 23:14:47 +08:00
}
}
2020-04-21 12:36:23 +08:00
public (int, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4), (bool hasResult, T5 result5), (bool hasResult, T6 result6), (bool hasResult, T7 result7), (bool hasResult, T8 result8), (bool hasResult, T9 result9), (bool hasResult, T10 result10), (bool hasResult, T11 result11), (bool hasResult, T12 result12), (bool hasResult, T13 result13), (bool hasResult, T14 result14), (bool hasResult, T15 result15)) GetResult(short token)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
TaskTracker2.RemoveTracking(this);
GC.SuppressFinalize(this);
return core.GetResult(token);
2019-05-19 23:14:47 +08:00
}
2020-04-21 12:36:23 +08:00
public UniTaskStatus GetStatus(short token)
2019-05-19 23:14:47 +08:00
{
2020-04-21 12:36:23 +08:00
return core.GetStatus(token);
}
2019-05-19 23:14:47 +08:00
2020-04-21 12:36:23 +08:00
public void OnCompleted(Action<object> continuation, object state, short token)
{
core.OnCompleted(continuation, state, token);
}
2019-05-19 23:14:47 +08:00
2020-04-21 12:36:23 +08:00
public UniTaskStatus UnsafeGetStatus()
{
return core.UnsafeGetStatus();
}
2019-05-19 23:14:47 +08:00
2020-04-21 12:36:23 +08:00
void IUniTaskSource.GetResult(short token)
{
GetResult(token);
}
2019-05-19 23:14:47 +08:00
2020-04-21 12:36:23 +08:00
~WhenAnyPromise()
{
core.Reset();
2019-05-19 23:14:47 +08:00
}
}
}
2020-04-21 12:36:23 +08:00
}