diff --git a/Assets/Scenes/SandboxMain.cs b/Assets/Scenes/SandboxMain.cs index 6417aa3..8d6fc4a 100644 --- a/Assets/Scenes/SandboxMain.cs +++ b/Assets/Scenes/SandboxMain.cs @@ -50,7 +50,7 @@ public class SandboxMain : MonoBehaviour { text.text = ""; - ucs.SetResult(); + ucs.TrySetResult(); await ucs.Task; }); diff --git a/Assets/UniRx.Async/CancellationTokenExtensions.cs b/Assets/UniRx.Async/CancellationTokenExtensions.cs index 3f9a89b..3e0fbc1 100644 --- a/Assets/UniRx.Async/CancellationTokenExtensions.cs +++ b/Assets/UniRx.Async/CancellationTokenExtensions.cs @@ -24,7 +24,7 @@ namespace UniRx.Async static void Callback(object state) { var promise = (UniTaskCompletionSource)state; - promise.SetResult(); + promise.TrySetResult(); } public static CancellationTokenRegistration RegisterWithoutCaptureExecutionContext(this CancellationToken cancellationToken, Action callback) diff --git a/Assets/UniRx.Async/CompilerServices/AsyncUniTaskMethodBuilder.cs b/Assets/UniRx.Async/CompilerServices/AsyncUniTaskMethodBuilder.cs index e53f0f2..0c10c95 100644 --- a/Assets/UniRx.Async/CompilerServices/AsyncUniTaskMethodBuilder.cs +++ b/Assets/UniRx.Async/CompilerServices/AsyncUniTaskMethodBuilder.cs @@ -60,7 +60,7 @@ namespace UniRx.Async.CompilerServices if (promise != null) { - promise.SetException(exception); + promise.TrySetException(exception); } else { @@ -81,7 +81,7 @@ namespace UniRx.Async.CompilerServices if (promise != null) { - promise.SetResult(); + promise.TrySetResult(); } } @@ -192,7 +192,7 @@ namespace UniRx.Async.CompilerServices } else { - promise.SetException(exception); + promise.TrySetException(exception); } } @@ -213,7 +213,7 @@ namespace UniRx.Async.CompilerServices return; } - promise.SetResult(result); + promise.TrySetResult(result); } // 5. AwaitOnCompleted diff --git a/Assets/UniRx.Async/Internal/StatePool.cs b/Assets/UniRx.Async/Internal/StatePool.cs index 7fe114b..9182952 100644 --- a/Assets/UniRx.Async/Internal/StatePool.cs +++ b/Assets/UniRx.Async/Internal/StatePool.cs @@ -6,6 +6,11 @@ namespace UniRx.Async.Internal { internal static class StateTuple { + public static StateTuple Create(T1 item1) + { + return StatePool.Create(item1); + } + public static StateTuple Create(T1 item1, T2 item2) { return StatePool.Create(item1, item2); @@ -17,6 +22,45 @@ namespace UniRx.Async.Internal } } + internal class StateTuple : IDisposable + { + public T1 Item1; + + public void Deconstruct(out T1 item1) + { + item1 = this.Item1; + } + + public void Dispose() + { + StatePool.Return(this); + } + } + + internal static class StatePool + { + static readonly ConcurrentQueue> queue = new ConcurrentQueue>(); + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static StateTuple Create(T1 item1) + { + if (queue.TryDequeue(out var value)) + { + value.Item1 = item1; + return value; + } + + return new StateTuple { Item1 = item1 }; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static void Return(StateTuple tuple) + { + tuple.Item1 = default; + queue.Enqueue(tuple); + } + } + internal class StateTuple : IDisposable { public T1 Item1; diff --git a/Assets/UniRx.Async/UniTask.Factory.cs b/Assets/UniRx.Async/UniTask.Factory.cs index 5878d91..c63d8c3 100644 --- a/Assets/UniRx.Async/UniTask.Factory.cs +++ b/Assets/UniRx.Async/UniTask.Factory.cs @@ -12,7 +12,7 @@ namespace UniRx.Async static readonly UniTask CanceledUniTask = new Func(() => { var promise = new UniTaskCompletionSource(); - promise.SetCanceled(CancellationToken.None); + promise.TrySetCanceled(CancellationToken.None); promise.MarkHandled(); return promise.Task; })(); @@ -24,7 +24,7 @@ namespace UniRx.Async static CanceledUniTaskCache() { var promise = new UniTaskCompletionSource(); - promise.SetCanceled(CancellationToken.None); + promise.TrySetCanceled(CancellationToken.None); promise.MarkHandled(); Task = promise.Task; } @@ -35,7 +35,7 @@ namespace UniRx.Async public static UniTask FromException(Exception ex) { var promise = new UniTaskCompletionSource(); - promise.SetException(ex); + promise.TrySetException(ex); promise.MarkHandled(); return promise.Task; } @@ -43,7 +43,7 @@ namespace UniRx.Async public static UniTask FromException(Exception ex) { var promise = new UniTaskCompletionSource(); - promise.SetException(ex); + promise.TrySetException(ex); promise.MarkHandled(); return promise.Task; } @@ -62,7 +62,7 @@ namespace UniRx.Async else { var promise = new UniTaskCompletionSource(); - promise.SetCanceled(cancellationToken); + promise.TrySetCanceled(cancellationToken); promise.MarkHandled(); return promise.Task; } @@ -77,7 +77,7 @@ namespace UniRx.Async else { var promise = new UniTaskCompletionSource(); - promise.SetCanceled(cancellationToken); + promise.TrySetCanceled(cancellationToken); promise.MarkHandled(); return promise.Task; } diff --git a/Assets/UniRx.Async/UniTask.WhenAny.Generated.cs b/Assets/UniRx.Async/UniTask.WhenAny.Generated.cs index 0773525..14a29b6 100644 --- a/Assets/UniRx.Async/UniTask.WhenAny.Generated.cs +++ b/Assets/UniRx.Async/UniTask.WhenAny.Generated.cs @@ -9,15 +9,15 @@ namespace UniRx.Async { public partial struct UniTask { - public static UniTask<(int winArgumentIndex, (bool hasResult, T1 result1), (bool hasResult, T2 result2))> WhenAny(UniTask task1, UniTask task2) + public static UniTask<(int winArgumentIndex, T1 result1, T2 result2)> WhenAny(UniTask task1, UniTask task2) { - return new UniTask<(int winArgumentIndex, (bool hasResult, T1 result1), (bool hasResult, T2 result2))>(new WhenAnyPromise(task1, task2), 0); + return new UniTask<(int winArgumentIndex, T1 result1, T2 result2)>(new WhenAnyPromise(task1, task2), 0); } - sealed class WhenAnyPromise : IUniTaskSource<(int, (bool hasResult, T1 result1), (bool hasResult, T2 result2))> + sealed class WhenAnyPromise : IUniTaskSource<(int, T1 result1, T2 result2)> { int completedCount; - UniTaskCompletionSourceCore<(int, (bool hasResult, T1 result1), (bool hasResult, T2 result2))> core; + UniTaskCompletionSourceCore<(int, T1 result1, T2 result2)> core; public WhenAnyPromise(UniTask task1, UniTask task2) { @@ -77,7 +77,7 @@ namespace UniRx.Async if (Interlocked.Increment(ref self.completedCount) == 1) { - self.core.TrySetResult((0, (true, result), (false, default))); + self.core.TrySetResult((0, result, default)); } } @@ -96,12 +96,12 @@ namespace UniRx.Async if (Interlocked.Increment(ref self.completedCount) == 1) { - self.core.TrySetResult((1, (false, default), (true, result))); + self.core.TrySetResult((1, default, result)); } } - public (int, (bool hasResult, T1 result1), (bool hasResult, T2 result2)) GetResult(short token) + public (int, T1 result1, T2 result2) GetResult(short token) { TaskTracker2.RemoveTracking(this); GC.SuppressFinalize(this); @@ -134,15 +134,15 @@ namespace UniRx.Async } } - public static UniTask<(int winArgumentIndex, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3))> WhenAny(UniTask task1, UniTask task2, UniTask task3) + public static UniTask<(int winArgumentIndex, T1 result1, T2 result2, T3 result3)> WhenAny(UniTask task1, UniTask task2, UniTask task3) { - return new UniTask<(int winArgumentIndex, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3))>(new WhenAnyPromise(task1, task2, task3), 0); + return new UniTask<(int winArgumentIndex, T1 result1, T2 result2, T3 result3)>(new WhenAnyPromise(task1, task2, task3), 0); } - sealed class WhenAnyPromise : IUniTaskSource<(int, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3))> + sealed class WhenAnyPromise : IUniTaskSource<(int, T1 result1, T2 result2, T3 result3)> { int completedCount; - UniTaskCompletionSourceCore<(int, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3))> core; + UniTaskCompletionSourceCore<(int, T1 result1, T2 result2, T3 result3)> core; public WhenAnyPromise(UniTask task1, UniTask task2, UniTask task3) { @@ -220,7 +220,7 @@ namespace UniRx.Async if (Interlocked.Increment(ref self.completedCount) == 1) { - self.core.TrySetResult((0, (true, result), (false, default), (false, default))); + self.core.TrySetResult((0, result, default, default)); } } @@ -239,7 +239,7 @@ namespace UniRx.Async if (Interlocked.Increment(ref self.completedCount) == 1) { - self.core.TrySetResult((1, (false, default), (true, result), (false, default))); + self.core.TrySetResult((1, default, result, default)); } } @@ -258,12 +258,12 @@ namespace UniRx.Async if (Interlocked.Increment(ref self.completedCount) == 1) { - self.core.TrySetResult((2, (false, default), (false, default), (true, result))); + self.core.TrySetResult((2, default, default, result)); } } - public (int, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3)) GetResult(short token) + public (int, T1 result1, T2 result2, T3 result3) GetResult(short token) { TaskTracker2.RemoveTracking(this); GC.SuppressFinalize(this); @@ -296,15 +296,15 @@ namespace UniRx.Async } } - public static UniTask<(int winArgumentIndex, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4))> WhenAny(UniTask task1, UniTask task2, UniTask task3, UniTask task4) + public static UniTask<(int winArgumentIndex, T1 result1, T2 result2, T3 result3, T4 result4)> WhenAny(UniTask task1, UniTask task2, UniTask task3, UniTask task4) { - return new UniTask<(int winArgumentIndex, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4))>(new WhenAnyPromise(task1, task2, task3, task4), 0); + return new UniTask<(int winArgumentIndex, T1 result1, T2 result2, T3 result3, T4 result4)>(new WhenAnyPromise(task1, task2, task3, task4), 0); } - sealed class WhenAnyPromise : IUniTaskSource<(int, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4))> + sealed class WhenAnyPromise : IUniTaskSource<(int, T1 result1, T2 result2, T3 result3, T4 result4)> { int completedCount; - UniTaskCompletionSourceCore<(int, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4))> core; + UniTaskCompletionSourceCore<(int, T1 result1, T2 result2, T3 result3, T4 result4)> core; public WhenAnyPromise(UniTask task1, UniTask task2, UniTask task3, UniTask task4) { @@ -400,7 +400,7 @@ namespace UniRx.Async if (Interlocked.Increment(ref self.completedCount) == 1) { - self.core.TrySetResult((0, (true, result), (false, default), (false, default), (false, default))); + self.core.TrySetResult((0, result, default, default, default)); } } @@ -419,7 +419,7 @@ namespace UniRx.Async if (Interlocked.Increment(ref self.completedCount) == 1) { - self.core.TrySetResult((1, (false, default), (true, result), (false, default), (false, default))); + self.core.TrySetResult((1, default, result, default, default)); } } @@ -438,7 +438,7 @@ namespace UniRx.Async if (Interlocked.Increment(ref self.completedCount) == 1) { - self.core.TrySetResult((2, (false, default), (false, default), (true, result), (false, default))); + self.core.TrySetResult((2, default, default, result, default)); } } @@ -457,12 +457,12 @@ namespace UniRx.Async if (Interlocked.Increment(ref self.completedCount) == 1) { - self.core.TrySetResult((3, (false, default), (false, default), (false, default), (true, result))); + self.core.TrySetResult((3, default, default, default, result)); } } - public (int, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4)) GetResult(short token) + public (int, T1 result1, T2 result2, T3 result3, T4 result4) GetResult(short token) { TaskTracker2.RemoveTracking(this); GC.SuppressFinalize(this); @@ -495,15 +495,15 @@ namespace UniRx.Async } } - 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(UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5) + public static UniTask<(int winArgumentIndex, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5)> WhenAny(UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask 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(task1, task2, task3, task4, task5), 0); + return new UniTask<(int winArgumentIndex, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5)>(new WhenAnyPromise(task1, task2, task3, task4, task5), 0); } - sealed class WhenAnyPromise : IUniTaskSource<(int, (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4), (bool hasResult, T5 result5))> + sealed class WhenAnyPromise : IUniTaskSource<(int, T1 result1, T2 result2, T3 result3, T4 result4, 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; + UniTaskCompletionSourceCore<(int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5)> core; public WhenAnyPromise(UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5) { @@ -617,7 +617,7 @@ namespace UniRx.Async if (Interlocked.Increment(ref self.completedCount) == 1) { - self.core.TrySetResult((0, (true, result), (false, default), (false, default), (false, default), (false, default))); + self.core.TrySetResult((0, result, default, default, default, default)); } } @@ -636,7 +636,7 @@ namespace UniRx.Async if (Interlocked.Increment(ref self.completedCount) == 1) { - self.core.TrySetResult((1, (false, default), (true, result), (false, default), (false, default), (false, default))); + self.core.TrySetResult((1, default, result, default, default, default)); } } @@ -655,7 +655,7 @@ namespace UniRx.Async if (Interlocked.Increment(ref self.completedCount) == 1) { - self.core.TrySetResult((2, (false, default), (false, default), (true, result), (false, default), (false, default))); + self.core.TrySetResult((2, default, default, result, default, default)); } } @@ -674,7 +674,7 @@ namespace UniRx.Async if (Interlocked.Increment(ref self.completedCount) == 1) { - self.core.TrySetResult((3, (false, default), (false, default), (false, default), (true, result), (false, default))); + self.core.TrySetResult((3, default, default, default, result, default)); } } @@ -693,12 +693,12 @@ namespace UniRx.Async if (Interlocked.Increment(ref self.completedCount) == 1) { - self.core.TrySetResult((4, (false, default), (false, default), (false, default), (false, default), (true, result))); + self.core.TrySetResult((4, default, default, default, default, result)); } } - 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) + public (int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5) GetResult(short token) { TaskTracker2.RemoveTracking(this); GC.SuppressFinalize(this); @@ -731,15 +731,15 @@ namespace UniRx.Async } } - 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(UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6) + public static UniTask<(int winArgumentIndex, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6)> WhenAny(UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask 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(task1, task2, task3, task4, task5, task6), 0); + return new UniTask<(int winArgumentIndex, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6)>(new WhenAnyPromise(task1, task2, task3, task4, task5, task6), 0); } - sealed class WhenAnyPromise : 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))> + sealed class WhenAnyPromise : IUniTaskSource<(int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, 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; + UniTaskCompletionSourceCore<(int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6)> core; public WhenAnyPromise(UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6) { @@ -871,7 +871,7 @@ namespace UniRx.Async if (Interlocked.Increment(ref self.completedCount) == 1) { - self.core.TrySetResult((0, (true, result), (false, default), (false, default), (false, default), (false, default), (false, default))); + self.core.TrySetResult((0, result, default, default, default, default, default)); } } @@ -890,7 +890,7 @@ namespace UniRx.Async if (Interlocked.Increment(ref self.completedCount) == 1) { - self.core.TrySetResult((1, (false, default), (true, result), (false, default), (false, default), (false, default), (false, default))); + self.core.TrySetResult((1, default, result, default, default, default, default)); } } @@ -909,7 +909,7 @@ namespace UniRx.Async if (Interlocked.Increment(ref self.completedCount) == 1) { - self.core.TrySetResult((2, (false, default), (false, default), (true, result), (false, default), (false, default), (false, default))); + self.core.TrySetResult((2, default, default, result, default, default, default)); } } @@ -928,7 +928,7 @@ namespace UniRx.Async if (Interlocked.Increment(ref self.completedCount) == 1) { - self.core.TrySetResult((3, (false, default), (false, default), (false, default), (true, result), (false, default), (false, default))); + self.core.TrySetResult((3, default, default, default, result, default, default)); } } @@ -947,7 +947,7 @@ namespace UniRx.Async if (Interlocked.Increment(ref self.completedCount) == 1) { - self.core.TrySetResult((4, (false, default), (false, default), (false, default), (false, default), (true, result), (false, default))); + self.core.TrySetResult((4, default, default, default, default, result, default)); } } @@ -966,12 +966,12 @@ namespace UniRx.Async if (Interlocked.Increment(ref self.completedCount) == 1) { - self.core.TrySetResult((5, (false, default), (false, default), (false, default), (false, default), (false, default), (true, result))); + self.core.TrySetResult((5, default, default, default, default, default, 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) + public (int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6) GetResult(short token) { TaskTracker2.RemoveTracking(this); GC.SuppressFinalize(this); @@ -1004,15 +1004,15 @@ namespace UniRx.Async } } - 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(UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6, UniTask task7) + public static UniTask<(int winArgumentIndex, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7)> WhenAny(UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6, UniTask 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(task1, task2, task3, task4, task5, task6, task7), 0); + return new UniTask<(int winArgumentIndex, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7)>(new WhenAnyPromise(task1, task2, task3, task4, task5, task6, task7), 0); } - sealed class WhenAnyPromise : 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))> + sealed class WhenAnyPromise : IUniTaskSource<(int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, 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; + UniTaskCompletionSourceCore<(int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7)> core; public WhenAnyPromise(UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6, UniTask task7) { @@ -1162,7 +1162,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((0, result, default, default, default, default, default, default)); } } @@ -1181,7 +1181,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((1, default, result, default, default, default, default, default)); } } @@ -1200,7 +1200,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((2, default, default, result, default, default, default, default)); } } @@ -1219,7 +1219,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((3, default, default, default, result, default, default, default)); } } @@ -1238,7 +1238,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((4, default, default, default, default, result, default, default)); } } @@ -1257,7 +1257,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((5, default, default, default, default, default, result, default)); } } @@ -1276,12 +1276,12 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((6, default, default, default, default, default, default, 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) + public (int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7) GetResult(short token) { TaskTracker2.RemoveTracking(this); GC.SuppressFinalize(this); @@ -1314,15 +1314,15 @@ namespace UniRx.Async } } - 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(UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6, UniTask task7, UniTask task8) + public static UniTask<(int winArgumentIndex, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7, T8 result8)> WhenAny(UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6, UniTask task7, UniTask 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(task1, task2, task3, task4, task5, task6, task7, task8), 0); + return new UniTask<(int winArgumentIndex, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7, T8 result8)>(new WhenAnyPromise(task1, task2, task3, task4, task5, task6, task7, task8), 0); } - sealed class WhenAnyPromise : 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))> + sealed class WhenAnyPromise : IUniTaskSource<(int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7, 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; + UniTaskCompletionSourceCore<(int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7, T8 result8)> core; public WhenAnyPromise(UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6, UniTask task7, UniTask task8) { @@ -1490,7 +1490,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((0, result, default, default, default, default, default, default, default)); } } @@ -1509,7 +1509,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((1, default, result, default, default, default, default, default, default)); } } @@ -1528,7 +1528,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((2, default, default, result, default, default, default, default, default)); } } @@ -1547,7 +1547,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((3, default, default, default, result, default, default, default, default)); } } @@ -1566,7 +1566,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((4, default, default, default, default, result, default, default, default)); } } @@ -1585,7 +1585,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((5, default, default, default, default, default, result, default, default)); } } @@ -1604,7 +1604,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((6, default, default, default, default, default, default, result, default)); } } @@ -1623,12 +1623,12 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((7, default, default, default, default, default, default, default, 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) + public (int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7, T8 result8) GetResult(short token) { TaskTracker2.RemoveTracking(this); GC.SuppressFinalize(this); @@ -1661,15 +1661,15 @@ namespace UniRx.Async } } - 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(UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6, UniTask task7, UniTask task8, UniTask task9) + public static UniTask<(int winArgumentIndex, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7, T8 result8, T9 result9)> WhenAny(UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6, UniTask task7, UniTask task8, UniTask 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(task1, task2, task3, task4, task5, task6, task7, task8, task9), 0); + return new UniTask<(int winArgumentIndex, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7, T8 result8, T9 result9)>(new WhenAnyPromise(task1, task2, task3, task4, task5, task6, task7, task8, task9), 0); } - sealed class WhenAnyPromise : 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))> + sealed class WhenAnyPromise : IUniTaskSource<(int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7, T8 result8, 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; + UniTaskCompletionSourceCore<(int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7, T8 result8, T9 result9)> core; public WhenAnyPromise(UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6, UniTask task7, UniTask task8, UniTask task9) { @@ -1855,7 +1855,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((0, result, default, default, default, default, default, default, default, default)); } } @@ -1874,7 +1874,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((1, default, result, default, default, default, default, default, default, default)); } } @@ -1893,7 +1893,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((2, default, default, result, default, default, default, default, default, default)); } } @@ -1912,7 +1912,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((3, default, default, default, result, default, default, default, default, default)); } } @@ -1931,7 +1931,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((4, default, default, default, default, result, default, default, default, default)); } } @@ -1950,7 +1950,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((5, default, default, default, default, default, result, default, default, default)); } } @@ -1969,7 +1969,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((6, default, default, default, default, default, default, result, default, default)); } } @@ -1988,7 +1988,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((7, default, default, default, default, default, default, default, result, default)); } } @@ -2007,12 +2007,12 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((8, default, default, default, default, default, default, default, default, 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) + public (int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7, T8 result8, T9 result9) GetResult(short token) { TaskTracker2.RemoveTracking(this); GC.SuppressFinalize(this); @@ -2045,15 +2045,15 @@ namespace UniRx.Async } } - 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(UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6, UniTask task7, UniTask task8, UniTask task9, UniTask task10) + public static UniTask<(int winArgumentIndex, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7, T8 result8, T9 result9, T10 result10)> WhenAny(UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6, UniTask task7, UniTask task8, UniTask task9, UniTask 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(task1, task2, task3, task4, task5, task6, task7, task8, task9, task10), 0); + return new UniTask<(int winArgumentIndex, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7, T8 result8, T9 result9, T10 result10)>(new WhenAnyPromise(task1, task2, task3, task4, task5, task6, task7, task8, task9, task10), 0); } - sealed class WhenAnyPromise : 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))> + sealed class WhenAnyPromise : IUniTaskSource<(int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7, T8 result8, T9 result9, 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; + UniTaskCompletionSourceCore<(int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7, T8 result8, T9 result9, T10 result10)> core; public WhenAnyPromise(UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6, UniTask task7, UniTask task8, UniTask task9, UniTask task10) { @@ -2257,7 +2257,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((0, result, default, default, default, default, default, default, default, default, default)); } } @@ -2276,7 +2276,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((1, default, result, default, default, default, default, default, default, default, default)); } } @@ -2295,7 +2295,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((2, default, default, result, default, default, default, default, default, default, default)); } } @@ -2314,7 +2314,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((3, default, default, default, result, default, default, default, default, default, default)); } } @@ -2333,7 +2333,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((4, default, default, default, default, result, default, default, default, default, default)); } } @@ -2352,7 +2352,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((5, default, default, default, default, default, result, default, default, default, default)); } } @@ -2371,7 +2371,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((6, default, default, default, default, default, default, result, default, default, default)); } } @@ -2390,7 +2390,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((7, default, default, default, default, default, default, default, result, default, default)); } } @@ -2409,7 +2409,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((8, default, default, default, default, default, default, default, default, result, default)); } } @@ -2428,12 +2428,12 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((9, default, default, default, default, default, default, default, default, default, 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) + public (int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7, T8 result8, T9 result9, T10 result10) GetResult(short token) { TaskTracker2.RemoveTracking(this); GC.SuppressFinalize(this); @@ -2466,15 +2466,15 @@ namespace UniRx.Async } } - 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(UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6, UniTask task7, UniTask task8, UniTask task9, UniTask task10, UniTask task11) + public static UniTask<(int winArgumentIndex, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7, T8 result8, T9 result9, T10 result10, T11 result11)> WhenAny(UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6, UniTask task7, UniTask task8, UniTask task9, UniTask task10, UniTask 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(task1, task2, task3, task4, task5, task6, task7, task8, task9, task10, task11), 0); + return new UniTask<(int winArgumentIndex, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7, T8 result8, T9 result9, T10 result10, T11 result11)>(new WhenAnyPromise(task1, task2, task3, task4, task5, task6, task7, task8, task9, task10, task11), 0); } - sealed class WhenAnyPromise : 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))> + sealed class WhenAnyPromise : IUniTaskSource<(int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7, T8 result8, T9 result9, T10 result10, 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; + UniTaskCompletionSourceCore<(int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7, T8 result8, T9 result9, T10 result10, T11 result11)> core; public WhenAnyPromise(UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6, UniTask task7, UniTask task8, UniTask task9, UniTask task10, UniTask task11) { @@ -2696,7 +2696,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((0, result, default, default, default, default, default, default, default, default, default, default)); } } @@ -2715,7 +2715,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((1, default, result, default, default, default, default, default, default, default, default, default)); } } @@ -2734,7 +2734,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((2, default, default, result, default, default, default, default, default, default, default, default)); } } @@ -2753,7 +2753,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((3, default, default, default, result, default, default, default, default, default, default, default)); } } @@ -2772,7 +2772,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((4, default, default, default, default, result, default, default, default, default, default, default)); } } @@ -2791,7 +2791,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((5, default, default, default, default, default, result, default, default, default, default, default)); } } @@ -2810,7 +2810,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((6, default, default, default, default, default, default, result, default, default, default, default)); } } @@ -2829,7 +2829,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((7, default, default, default, default, default, default, default, result, default, default, default)); } } @@ -2848,7 +2848,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((8, default, default, default, default, default, default, default, default, result, default, default)); } } @@ -2867,7 +2867,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((9, default, default, default, default, default, default, default, default, default, result, default)); } } @@ -2886,12 +2886,12 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((10, default, default, default, default, default, default, default, default, default, default, 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) + public (int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7, T8 result8, T9 result9, T10 result10, T11 result11) GetResult(short token) { TaskTracker2.RemoveTracking(this); GC.SuppressFinalize(this); @@ -2924,15 +2924,15 @@ namespace UniRx.Async } } - 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(UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6, UniTask task7, UniTask task8, UniTask task9, UniTask task10, UniTask task11, UniTask task12) + public static UniTask<(int winArgumentIndex, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7, T8 result8, T9 result9, T10 result10, T11 result11, T12 result12)> WhenAny(UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6, UniTask task7, UniTask task8, UniTask task9, UniTask task10, UniTask task11, UniTask 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(task1, task2, task3, task4, task5, task6, task7, task8, task9, task10, task11, task12), 0); + return new UniTask<(int winArgumentIndex, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7, T8 result8, T9 result9, T10 result10, T11 result11, T12 result12)>(new WhenAnyPromise(task1, task2, task3, task4, task5, task6, task7, task8, task9, task10, task11, task12), 0); } - sealed class WhenAnyPromise : 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))> + sealed class WhenAnyPromise : IUniTaskSource<(int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7, T8 result8, T9 result9, T10 result10, T11 result11, 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; + UniTaskCompletionSourceCore<(int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7, T8 result8, T9 result9, T10 result10, T11 result11, T12 result12)> core; public WhenAnyPromise(UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6, UniTask task7, UniTask task8, UniTask task9, UniTask task10, UniTask task11, UniTask task12) { @@ -3172,7 +3172,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((0, result, default, default, default, default, default, default, default, default, default, default, default)); } } @@ -3191,7 +3191,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((1, default, result, default, default, default, default, default, default, default, default, default, default)); } } @@ -3210,7 +3210,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((2, default, default, result, default, default, default, default, default, default, default, default, default)); } } @@ -3229,7 +3229,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((3, default, default, default, result, default, default, default, default, default, default, default, default)); } } @@ -3248,7 +3248,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((4, default, default, default, default, result, default, default, default, default, default, default, default)); } } @@ -3267,7 +3267,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((5, default, default, default, default, default, result, default, default, default, default, default, default)); } } @@ -3286,7 +3286,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((6, default, default, default, default, default, default, result, default, default, default, default, default)); } } @@ -3305,7 +3305,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((7, default, default, default, default, default, default, default, result, default, default, default, default)); } } @@ -3324,7 +3324,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((8, default, default, default, default, default, default, default, default, result, default, default, default)); } } @@ -3343,7 +3343,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((9, default, default, default, default, default, default, default, default, default, result, default, default)); } } @@ -3362,7 +3362,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((10, default, default, default, default, default, default, default, default, default, default, result, default)); } } @@ -3381,12 +3381,12 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((11, default, default, default, default, default, default, default, default, default, default, default, 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) + public (int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7, T8 result8, T9 result9, T10 result10, T11 result11, T12 result12) GetResult(short token) { TaskTracker2.RemoveTracking(this); GC.SuppressFinalize(this); @@ -3419,15 +3419,15 @@ namespace UniRx.Async } } - 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(UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6, UniTask task7, UniTask task8, UniTask task9, UniTask task10, UniTask task11, UniTask task12, UniTask task13) + public static UniTask<(int winArgumentIndex, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7, T8 result8, T9 result9, T10 result10, T11 result11, T12 result12, T13 result13)> WhenAny(UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6, UniTask task7, UniTask task8, UniTask task9, UniTask task10, UniTask task11, UniTask task12, UniTask 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(task1, task2, task3, task4, task5, task6, task7, task8, task9, task10, task11, task12, task13), 0); + return new UniTask<(int winArgumentIndex, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7, T8 result8, T9 result9, T10 result10, T11 result11, T12 result12, T13 result13)>(new WhenAnyPromise(task1, task2, task3, task4, task5, task6, task7, task8, task9, task10, task11, task12, task13), 0); } - sealed class WhenAnyPromise : 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))> + sealed class WhenAnyPromise : IUniTaskSource<(int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7, T8 result8, T9 result9, T10 result10, T11 result11, T12 result12, 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; + UniTaskCompletionSourceCore<(int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7, T8 result8, T9 result9, T10 result10, T11 result11, T12 result12, T13 result13)> core; public WhenAnyPromise(UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6, UniTask task7, UniTask task8, UniTask task9, UniTask task10, UniTask task11, UniTask task12, UniTask task13) { @@ -3685,7 +3685,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((0, result, default, default, default, default, default, default, default, default, default, default, default, default)); } } @@ -3704,7 +3704,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((1, default, result, default, default, default, default, default, default, default, default, default, default, default)); } } @@ -3723,7 +3723,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((2, default, default, result, default, default, default, default, default, default, default, default, default, default)); } } @@ -3742,7 +3742,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((3, default, default, default, result, default, default, default, default, default, default, default, default, default)); } } @@ -3761,7 +3761,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((4, default, default, default, default, result, default, default, default, default, default, default, default, default)); } } @@ -3780,7 +3780,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((5, default, default, default, default, default, result, default, default, default, default, default, default, default)); } } @@ -3799,7 +3799,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((6, default, default, default, default, default, default, result, default, default, default, default, default, default)); } } @@ -3818,7 +3818,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((7, default, default, default, default, default, default, default, result, default, default, default, default, default)); } } @@ -3837,7 +3837,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((8, default, default, default, default, default, default, default, default, result, default, default, default, default)); } } @@ -3856,7 +3856,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((9, default, default, default, default, default, default, default, default, default, result, default, default, default)); } } @@ -3875,7 +3875,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((10, default, default, default, default, default, default, default, default, default, default, result, default, default)); } } @@ -3894,7 +3894,7 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((11, default, default, default, default, default, default, default, default, default, default, default, result, default)); } } @@ -3913,12 +3913,12 @@ namespace UniRx.Async 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))); + self.core.TrySetResult((12, default, default, default, default, default, default, default, default, default, default, default, default, 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) + public (int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7, T8 result8, T9 result9, T10 result10, T11 result11, T12 result12, T13 result13) GetResult(short token) { TaskTracker2.RemoveTracking(this); GC.SuppressFinalize(this); @@ -3951,15 +3951,15 @@ namespace UniRx.Async } } - 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(UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6, UniTask task7, UniTask task8, UniTask task9, UniTask task10, UniTask task11, UniTask task12, UniTask task13, UniTask task14) + public static UniTask<(int winArgumentIndex, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7, T8 result8, T9 result9, T10 result10, T11 result11, T12 result12, T13 result13, T14 result14)> WhenAny(UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6, UniTask task7, UniTask task8, UniTask task9, UniTask task10, UniTask task11, UniTask task12, UniTask task13, UniTask 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(task1, task2, task3, task4, task5, task6, task7, task8, task9, task10, task11, task12, task13, task14), 0); + return new UniTask<(int winArgumentIndex, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7, T8 result8, T9 result9, T10 result10, T11 result11, T12 result12, T13 result13, T14 result14)>(new WhenAnyPromise(task1, task2, task3, task4, task5, task6, task7, task8, task9, task10, task11, task12, task13, task14), 0); } - sealed class WhenAnyPromise : 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))> + sealed class WhenAnyPromise : IUniTaskSource<(int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7, T8 result8, T9 result9, T10 result10, T11 result11, T12 result12, T13 result13, 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; + UniTaskCompletionSourceCore<(int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7, T8 result8, T9 result9, T10 result10, T11 result11, T12 result12, T13 result13, T14 result14)> core; public WhenAnyPromise(UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6, UniTask task7, UniTask task8, UniTask task9, UniTask task10, UniTask task11, UniTask task12, UniTask task13, UniTask task14) { @@ -4235,7 +4235,7 @@ namespace UniRx.Async 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), (false, default))); + self.core.TrySetResult((0, result, default, default, default, default, default, default, default, default, default, default, default, default, default)); } } @@ -4254,7 +4254,7 @@ namespace UniRx.Async 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), (false, default))); + self.core.TrySetResult((1, default, result, default, default, default, default, default, default, default, default, default, default, default, default)); } } @@ -4273,7 +4273,7 @@ namespace UniRx.Async 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), (false, default))); + self.core.TrySetResult((2, default, default, result, default, default, default, default, default, default, default, default, default, default, default)); } } @@ -4292,7 +4292,7 @@ namespace UniRx.Async 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), (false, default))); + self.core.TrySetResult((3, default, default, default, result, default, default, default, default, default, default, default, default, default, default)); } } @@ -4311,7 +4311,7 @@ namespace UniRx.Async 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), (false, default))); + self.core.TrySetResult((4, default, default, default, default, result, default, default, default, default, default, default, default, default, default)); } } @@ -4330,7 +4330,7 @@ namespace UniRx.Async 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), (false, default))); + self.core.TrySetResult((5, default, default, default, default, default, result, default, default, default, default, default, default, default, default)); } } @@ -4349,7 +4349,7 @@ namespace UniRx.Async 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), (false, default))); + self.core.TrySetResult((6, default, default, default, default, default, default, result, default, default, default, default, default, default, default)); } } @@ -4368,7 +4368,7 @@ namespace UniRx.Async 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), (false, default))); + self.core.TrySetResult((7, default, default, default, default, default, default, default, result, default, default, default, default, default, default)); } } @@ -4387,7 +4387,7 @@ namespace UniRx.Async 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), (false, default))); + self.core.TrySetResult((8, default, default, default, default, default, default, default, default, result, default, default, default, default, default)); } } @@ -4406,7 +4406,7 @@ namespace UniRx.Async 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), (false, default))); + self.core.TrySetResult((9, default, default, default, default, default, default, default, default, default, result, default, default, default, default)); } } @@ -4425,7 +4425,7 @@ namespace UniRx.Async 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), (false, default))); + self.core.TrySetResult((10, default, default, default, default, default, default, default, default, default, default, result, default, default, default)); } } @@ -4444,7 +4444,7 @@ namespace UniRx.Async 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), (false, default))); + self.core.TrySetResult((11, default, default, default, default, default, default, default, default, default, default, default, result, default, default)); } } @@ -4463,7 +4463,7 @@ namespace UniRx.Async 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), (false, default))); + self.core.TrySetResult((12, default, default, default, default, default, default, default, default, default, default, default, default, result, default)); } } @@ -4482,12 +4482,12 @@ namespace UniRx.Async if (Interlocked.Increment(ref self.completedCount) == 1) { - 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))); + self.core.TrySetResult((13, default, default, default, default, default, default, default, default, default, default, default, default, default, 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), (bool hasResult, T14 result14)) GetResult(short token) + public (int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7, T8 result8, T9 result9, T10 result10, T11 result11, T12 result12, T13 result13, T14 result14) GetResult(short token) { TaskTracker2.RemoveTracking(this); GC.SuppressFinalize(this); @@ -4520,15 +4520,15 @@ namespace UniRx.Async } } - 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(UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6, UniTask task7, UniTask task8, UniTask task9, UniTask task10, UniTask task11, UniTask task12, UniTask task13, UniTask task14, UniTask task15) + public static UniTask<(int winArgumentIndex, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7, T8 result8, T9 result9, T10 result10, T11 result11, T12 result12, T13 result13, T14 result14, T15 result15)> WhenAny(UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6, UniTask task7, UniTask task8, UniTask task9, UniTask task10, UniTask task11, UniTask task12, UniTask task13, UniTask task14, UniTask 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(task1, task2, task3, task4, task5, task6, task7, task8, task9, task10, task11, task12, task13, task14, task15), 0); + return new UniTask<(int winArgumentIndex, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7, T8 result8, T9 result9, T10 result10, T11 result11, T12 result12, T13 result13, T14 result14, T15 result15)>(new WhenAnyPromise(task1, task2, task3, task4, task5, task6, task7, task8, task9, task10, task11, task12, task13, task14, task15), 0); } - sealed class WhenAnyPromise : 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))> + sealed class WhenAnyPromise : IUniTaskSource<(int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7, T8 result8, T9 result9, T10 result10, T11 result11, T12 result12, T13 result13, T14 result14, 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; + UniTaskCompletionSourceCore<(int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7, T8 result8, T9 result9, T10 result10, T11 result11, T12 result12, T13 result13, T14 result14, T15 result15)> core; public WhenAnyPromise(UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6, UniTask task7, UniTask task8, UniTask task9, UniTask task10, UniTask task11, UniTask task12, UniTask task13, UniTask task14, UniTask task15) { @@ -4822,7 +4822,7 @@ namespace UniRx.Async 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), (false, default), (false, default))); + self.core.TrySetResult((0, result, default, default, default, default, default, default, default, default, default, default, default, default, default, default)); } } @@ -4841,7 +4841,7 @@ namespace UniRx.Async 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), (false, default), (false, default))); + self.core.TrySetResult((1, default, result, default, default, default, default, default, default, default, default, default, default, default, default, default)); } } @@ -4860,7 +4860,7 @@ namespace UniRx.Async 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), (false, default), (false, default))); + self.core.TrySetResult((2, default, default, result, default, default, default, default, default, default, default, default, default, default, default, default)); } } @@ -4879,7 +4879,7 @@ namespace UniRx.Async 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), (false, default), (false, default))); + self.core.TrySetResult((3, default, default, default, result, default, default, default, default, default, default, default, default, default, default, default)); } } @@ -4898,7 +4898,7 @@ namespace UniRx.Async 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), (false, default), (false, default))); + self.core.TrySetResult((4, default, default, default, default, result, default, default, default, default, default, default, default, default, default, default)); } } @@ -4917,7 +4917,7 @@ namespace UniRx.Async 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), (false, default), (false, default))); + self.core.TrySetResult((5, default, default, default, default, default, result, default, default, default, default, default, default, default, default, default)); } } @@ -4936,7 +4936,7 @@ namespace UniRx.Async 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), (false, default), (false, default))); + self.core.TrySetResult((6, default, default, default, default, default, default, result, default, default, default, default, default, default, default, default)); } } @@ -4955,7 +4955,7 @@ namespace UniRx.Async 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), (false, default), (false, default))); + self.core.TrySetResult((7, default, default, default, default, default, default, default, result, default, default, default, default, default, default, default)); } } @@ -4974,7 +4974,7 @@ namespace UniRx.Async 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), (false, default), (false, default))); + self.core.TrySetResult((8, default, default, default, default, default, default, default, default, result, default, default, default, default, default, default)); } } @@ -4993,7 +4993,7 @@ namespace UniRx.Async 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), (false, default), (false, default))); + self.core.TrySetResult((9, default, default, default, default, default, default, default, default, default, result, default, default, default, default, default)); } } @@ -5012,7 +5012,7 @@ namespace UniRx.Async 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), (false, default), (false, default))); + self.core.TrySetResult((10, default, default, default, default, default, default, default, default, default, default, result, default, default, default, default)); } } @@ -5031,7 +5031,7 @@ namespace UniRx.Async 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), (false, default), (false, default))); + self.core.TrySetResult((11, default, default, default, default, default, default, default, default, default, default, default, result, default, default, default)); } } @@ -5050,7 +5050,7 @@ namespace UniRx.Async 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), (false, default), (false, default))); + self.core.TrySetResult((12, default, default, default, default, default, default, default, default, default, default, default, default, result, default, default)); } } @@ -5069,7 +5069,7 @@ namespace UniRx.Async if (Interlocked.Increment(ref self.completedCount) == 1) { - 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))); + self.core.TrySetResult((13, default, default, default, default, default, default, default, default, default, default, default, default, default, result, default)); } } @@ -5088,12 +5088,12 @@ namespace UniRx.Async if (Interlocked.Increment(ref self.completedCount) == 1) { - 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))); + self.core.TrySetResult((14, default, default, default, default, default, default, default, default, default, default, default, default, default, default, 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), (bool hasResult, T14 result14), (bool hasResult, T15 result15)) GetResult(short token) + public (int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7, T8 result8, T9 result9, T10 result10, T11 result11, T12 result12, T13 result13, T14 result14, T15 result15) GetResult(short token) { TaskTracker2.RemoveTracking(this); GC.SuppressFinalize(this); diff --git a/Assets/UniRx.Async/UniTask.WhenAny.Generated.tt b/Assets/UniRx.Async/UniTask.WhenAny.Generated.tt index 3d50260..ab66053 100644 --- a/Assets/UniRx.Async/UniTask.WhenAny.Generated.tt +++ b/Assets/UniRx.Async/UniTask.WhenAny.Generated.tt @@ -21,9 +21,9 @@ namespace UniRx.Async var args = string.Join(", ", range.Select(x => $"UniTask task{x}")); var targs = string.Join(", ", range.Select(x => $"task{x}")); var tresult = string.Join(", ", range.Select(x => $"task{x}.GetAwaiter().GetResult()")); - var tBool = string.Join(", ", range.Select(x => $"(bool hasResult, T{x} result{x})")); + var tBool = string.Join(", ", range.Select(x => $"T{x} result{x}")); var tfield = string.Join(", ", range.Select(x => $"self.t{x}")); - Func getResult = j => string.Join(", ", range.Select(x => (x == j) ? "(true, result)" : "(false, default)")); + Func getResult = j => string.Join(", ", range.Select(x => (x == j) ? "result" : "default")); #> public static UniTask<(int winArgumentIndex, <#= tBool #>)> WhenAny<<#= t #>>(<#= args #>) { diff --git a/Assets/UniRx.Async/UniTask.cs b/Assets/UniRx.Async/UniTask.cs index 5a372a7..bc7fe96 100644 --- a/Assets/UniRx.Async/UniTask.cs +++ b/Assets/UniRx.Async/UniTask.cs @@ -403,6 +403,7 @@ namespace UniRx.Async return UniTask.CompletedTask; } + // Converting UniTask -> UniTask is zero overhead. return new UniTask(this.source, this.token); } diff --git a/Assets/UniRx.Async/UniTaskCompletionSource.cs b/Assets/UniRx.Async/UniTaskCompletionSource.cs index 89d700d..ccc4f4a 100644 --- a/Assets/UniRx.Async/UniTaskCompletionSource.cs +++ b/Assets/UniRx.Async/UniTaskCompletionSource.cs @@ -13,22 +13,22 @@ namespace UniRx.Async { public interface IResolvePromise { - void SetResult(); + bool TrySetResult(); } public interface IResolvePromise { - void SetResult(T value); + bool TrySetResult(T value); } public interface IRejectPromise { - void SetException(Exception exception); + bool TrySetException(Exception exception); } public interface ICancelPromise { - void SetCanceled(CancellationToken cancellationToken = default); + bool TrySetCanceled(CancellationToken cancellationToken = default); } public interface IPromise : IResolvePromise, IRejectPromise, ICancelPromise @@ -301,19 +301,19 @@ namespace UniRx.Async core.Reset(); } - public void SetResult() + public bool TrySetResult() { - core.TrySetResult(AsyncUnit.Default); + return core.TrySetResult(AsyncUnit.Default); } - public void SetCanceled(CancellationToken cancellationToken = default) + public bool TrySetCanceled(CancellationToken cancellationToken = default) { - core.TrySetCanceled(cancellationToken); + return core.TrySetCanceled(cancellationToken); } - public void SetException(Exception exception) + public bool TrySetException(Exception exception) { - core.TrySetException(exception); + return core.TrySetException(exception); } public void GetResult(short token) @@ -364,7 +364,7 @@ namespace UniRx.Async public static AutoResetUniTaskCompletionSource CreateFromCanceled(CancellationToken cancellationToken, out short token) { var source = Create(); - source.SetCanceled(cancellationToken); + source.TrySetCanceled(cancellationToken); token = source.core.Version; return source; } @@ -372,7 +372,7 @@ namespace UniRx.Async public static AutoResetUniTaskCompletionSource CreateFromException(Exception exception, out short token) { var source = Create(); - source.SetException(exception); + source.TrySetException(exception); token = source.core.Version; return source; } @@ -380,7 +380,7 @@ namespace UniRx.Async public static AutoResetUniTaskCompletionSource CreateCompleted(out short token) { var source = Create(); - source.SetResult(); + source.TrySetResult(); token = source.core.Version; return source; } @@ -393,19 +393,19 @@ namespace UniRx.Async } } - public void SetResult() + public bool TrySetResult() { - core.TrySetResult(AsyncUnit.Default); + return core.TrySetResult(AsyncUnit.Default); } - public void SetCanceled(CancellationToken cancellationToken = default) + public bool TrySetCanceled(CancellationToken cancellationToken = default) { - core.TrySetCanceled(cancellationToken); + return core.TrySetCanceled(cancellationToken); } - public void SetException(Exception exception) + public bool TrySetException(Exception exception) { - core.TrySetException(exception); + return core.TrySetException(exception); } public void GetResult(short token) @@ -487,19 +487,19 @@ namespace UniRx.Async TaskTracker2.TrackActiveTask(this, 2); } - public void SetResult(T result) + public bool TrySetResult(T result) { - core.TrySetResult(result); + return core.TrySetResult(result); } - public void SetCanceled(CancellationToken cancellationToken = default) + public bool TrySetCanceled(CancellationToken cancellationToken = default) { - core.TrySetCanceled(cancellationToken); + return core.TrySetCanceled(cancellationToken); } - public void SetException(Exception exception) + public bool TrySetException(Exception exception) { - core.TrySetException(exception); + return core.TrySetException(exception); } public T GetResult(short token) @@ -555,7 +555,7 @@ namespace UniRx.Async public static AutoResetUniTaskCompletionSource CreateFromCanceled(CancellationToken cancellationToken, out short token) { var source = Create(); - source.SetCanceled(cancellationToken); + source.TrySetCanceled(cancellationToken); token = source.core.Version; return source; } @@ -563,7 +563,7 @@ namespace UniRx.Async public static AutoResetUniTaskCompletionSource CreateFromException(Exception exception, out short token) { var source = Create(); - source.SetException(exception); + source.TrySetException(exception); token = source.core.Version; return source; } @@ -571,7 +571,7 @@ namespace UniRx.Async public static AutoResetUniTaskCompletionSource CreateFromResult(T result, out short token) { var source = Create(); - source.SetResult(result); + source.TrySetResult(result); token = source.core.Version; return source; } @@ -584,19 +584,19 @@ namespace UniRx.Async } } - public void SetResult(T result) + public bool TrySetResult(T result) { - core.TrySetResult(result); + return core.TrySetResult(result); } - public void SetCanceled(CancellationToken cancellationToken = default) + public bool TrySetCanceled(CancellationToken cancellationToken = default) { - core.TrySetCanceled(cancellationToken); + return core.TrySetCanceled(cancellationToken); } - public void SetException(Exception exception) + public bool TrySetException(Exception exception) { - core.TrySetException(exception); + return core.TrySetException(exception); } public T GetResult(short token) diff --git a/Assets/UniRx.Async/UniTaskExtensions.Shorthand.cs b/Assets/UniRx.Async/UniTaskExtensions.Shorthand.cs index 235bcac..37fdd80 100644 --- a/Assets/UniRx.Async/UniTaskExtensions.Shorthand.cs +++ b/Assets/UniRx.Async/UniTaskExtensions.Shorthand.cs @@ -1,6 +1,4 @@ -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - +#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member using System.Collections.Generic; namespace UniRx.Async @@ -8,46 +6,182 @@ namespace UniRx.Async public static partial class UniTaskExtensions { // shorthand of WhenAll + + public static UniTask.Awaiter GetAwaiter(this UniTask[] tasks) + { + return UniTask.WhenAll(tasks).GetAwaiter(); + } public static UniTask.Awaiter GetAwaiter(this IEnumerable tasks) { return UniTask.WhenAll(tasks).GetAwaiter(); } + public static UniTask.Awaiter GetAwaiter(this UniTask[] tasks) + { + return UniTask.WhenAll(tasks).GetAwaiter(); + } + public static UniTask.Awaiter GetAwaiter(this IEnumerable> tasks) { return UniTask.WhenAll(tasks).GetAwaiter(); } - public static UniTask<(T1 result1, T2 result2)>.Awaiter GetAwaiter(this (UniTask task1, UniTask task2) tasks) + public static UniTask<(T1, T2)>.Awaiter GetAwaiter(this (UniTask task1, UniTask task2) tasks) { - return UniTask.WhenAll(tasks.task1, tasks.task2).GetAwaiter(); + return UniTask.WhenAll(tasks.Item1, tasks.Item2).GetAwaiter(); } - public static UniTask<(T1 result1, T2 result2, T3 result3)> WhenAll(this (UniTask task1, UniTask task2, UniTask task3) tasks) + public static UniTask<(T1, T2, T3)>.Awaiter GetAwaiter(this (UniTask task1, UniTask task2, UniTask task3) tasks) { - return UniTask.WhenAll(tasks.task1, tasks.task2, tasks.task3); + return UniTask.WhenAll(tasks.Item1, tasks.Item2, tasks.Item3).GetAwaiter(); } - public static UniTask<(T1 result1, T2 result2, T3 result3, T4 result4)> WhenAll(this (UniTask task1, UniTask task2, UniTask task3, UniTask task4) tasks) + public static UniTask<(T1, T2, T3, T4)>.Awaiter GetAwaiter(this (UniTask task1, UniTask task2, UniTask task3, UniTask task4) tasks) { - return UniTask.WhenAll(tasks.task1, tasks.task2, tasks.task3, tasks.task4); + return UniTask.WhenAll(tasks.Item1, tasks.Item2, tasks.Item3, tasks.Item4).GetAwaiter(); } - public static UniTask<(T1 result1, T2 result2, T3 result3, T4 result4, T5 result5)> WhenAll(this (UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5) tasks) + public static UniTask<(T1, T2, T3, T4, T5)>.Awaiter GetAwaiter(this (UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5) tasks) { - return UniTask.WhenAll(tasks.task1, tasks.task2, tasks.task3, tasks.task4, tasks.task5); + return UniTask.WhenAll(tasks.Item1, tasks.Item2, tasks.Item3, tasks.Item4, tasks.Item5).GetAwaiter(); } - public static UniTask<(T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6)> WhenAll(this (UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6) tasks) + public static UniTask<(T1, T2, T3, T4, T5, T6)>.Awaiter GetAwaiter(this (UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6) tasks) { - return UniTask.WhenAll(tasks.task1, tasks.task2, tasks.task3, tasks.task4, tasks.task5, tasks.task6); + return UniTask.WhenAll(tasks.Item1, tasks.Item2, tasks.Item3, tasks.Item4, tasks.Item5, tasks.Item6).GetAwaiter(); } - public static UniTask<(T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7)> WhenAll(this (UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6, UniTask task7) tasks) + public static UniTask<(T1, T2, T3, T4, T5, T6, T7)>.Awaiter GetAwaiter(this (UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6, UniTask task7) tasks) { - return UniTask.WhenAll(tasks.task1, tasks.task2, tasks.task3, tasks.task4, tasks.task5, tasks.task6, tasks.task7); + return UniTask.WhenAll(tasks.Item1, tasks.Item2, tasks.Item3, tasks.Item4, tasks.Item5, tasks.Item6, tasks.Item7).GetAwaiter(); } + + public static UniTask<(T1, T2, T3, T4, T5, T6, T7, T8)>.Awaiter GetAwaiter(this (UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6, UniTask task7, UniTask task8) tasks) + { + return UniTask.WhenAll(tasks.Item1, tasks.Item2, tasks.Item3, tasks.Item4, tasks.Item5, tasks.Item6, tasks.Item7, tasks.Item8).GetAwaiter(); + } + + public static UniTask<(T1, T2, T3, T4, T5, T6, T7, T8, T9)>.Awaiter GetAwaiter(this (UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6, UniTask task7, UniTask task8, UniTask task9) tasks) + { + return UniTask.WhenAll(tasks.Item1, tasks.Item2, tasks.Item3, tasks.Item4, tasks.Item5, tasks.Item6, tasks.Item7, tasks.Item8, tasks.Item9).GetAwaiter(); + } + + public static UniTask<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)>.Awaiter GetAwaiter(this (UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6, UniTask task7, UniTask task8, UniTask task9, UniTask task10) tasks) + { + return UniTask.WhenAll(tasks.Item1, tasks.Item2, tasks.Item3, tasks.Item4, tasks.Item5, tasks.Item6, tasks.Item7, tasks.Item8, tasks.Item9, tasks.Item10).GetAwaiter(); + } + + public static UniTask<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)>.Awaiter GetAwaiter(this (UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6, UniTask task7, UniTask task8, UniTask task9, UniTask task10, UniTask task11) tasks) + { + return UniTask.WhenAll(tasks.Item1, tasks.Item2, tasks.Item3, tasks.Item4, tasks.Item5, tasks.Item6, tasks.Item7, tasks.Item8, tasks.Item9, tasks.Item10, tasks.Item11).GetAwaiter(); + } + + public static UniTask<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12)>.Awaiter GetAwaiter(this (UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6, UniTask task7, UniTask task8, UniTask task9, UniTask task10, UniTask task11, UniTask task12) tasks) + { + return UniTask.WhenAll(tasks.Item1, tasks.Item2, tasks.Item3, tasks.Item4, tasks.Item5, tasks.Item6, tasks.Item7, tasks.Item8, tasks.Item9, tasks.Item10, tasks.Item11, tasks.Item12).GetAwaiter(); + } + + public static UniTask<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13)>.Awaiter GetAwaiter(this (UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6, UniTask task7, UniTask task8, UniTask task9, UniTask task10, UniTask task11, UniTask task12, UniTask task13) tasks) + { + return UniTask.WhenAll(tasks.Item1, tasks.Item2, tasks.Item3, tasks.Item4, tasks.Item5, tasks.Item6, tasks.Item7, tasks.Item8, tasks.Item9, tasks.Item10, tasks.Item11, tasks.Item12, tasks.Item13).GetAwaiter(); + } + + public static UniTask<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14)>.Awaiter GetAwaiter(this (UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6, UniTask task7, UniTask task8, UniTask task9, UniTask task10, UniTask task11, UniTask task12, UniTask task13, UniTask task14) tasks) + { + return UniTask.WhenAll(tasks.Item1, tasks.Item2, tasks.Item3, tasks.Item4, tasks.Item5, tasks.Item6, tasks.Item7, tasks.Item8, tasks.Item9, tasks.Item10, tasks.Item11, tasks.Item12, tasks.Item13, tasks.Item14).GetAwaiter(); + } + + public static UniTask<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15)>.Awaiter GetAwaiter(this (UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6, UniTask task7, UniTask task8, UniTask task9, UniTask task10, UniTask task11, UniTask task12, UniTask task13, UniTask task14, UniTask task15) tasks) + { + return UniTask.WhenAll(tasks.Item1, tasks.Item2, tasks.Item3, tasks.Item4, tasks.Item5, tasks.Item6, tasks.Item7, tasks.Item8, tasks.Item9, tasks.Item10, tasks.Item11, tasks.Item12, tasks.Item13, tasks.Item14, tasks.Item15).GetAwaiter(); + } + + + + public static UniTask.Awaiter GetAwaiter(this (UniTask task1, UniTask task2) tasks) + { + return UniTask.WhenAll(tasks.Item1, tasks.Item2).GetAwaiter(); + } + + + public static UniTask.Awaiter GetAwaiter(this (UniTask task1, UniTask task2, UniTask task3) tasks) + { + return UniTask.WhenAll(tasks.Item1, tasks.Item2, tasks.Item3).GetAwaiter(); + } + + + public static UniTask.Awaiter GetAwaiter(this (UniTask task1, UniTask task2, UniTask task3, UniTask task4) tasks) + { + return UniTask.WhenAll(tasks.Item1, tasks.Item2, tasks.Item3, tasks.Item4).GetAwaiter(); + } + + + public static UniTask.Awaiter GetAwaiter(this (UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5) tasks) + { + return UniTask.WhenAll(tasks.Item1, tasks.Item2, tasks.Item3, tasks.Item4, tasks.Item5).GetAwaiter(); + } + + + public static UniTask.Awaiter GetAwaiter(this (UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6) tasks) + { + return UniTask.WhenAll(tasks.Item1, tasks.Item2, tasks.Item3, tasks.Item4, tasks.Item5, tasks.Item6).GetAwaiter(); + } + + + public static UniTask.Awaiter GetAwaiter(this (UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6, UniTask task7) tasks) + { + return UniTask.WhenAll(tasks.Item1, tasks.Item2, tasks.Item3, tasks.Item4, tasks.Item5, tasks.Item6, tasks.Item7).GetAwaiter(); + } + + + public static UniTask.Awaiter GetAwaiter(this (UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6, UniTask task7, UniTask task8) tasks) + { + return UniTask.WhenAll(tasks.Item1, tasks.Item2, tasks.Item3, tasks.Item4, tasks.Item5, tasks.Item6, tasks.Item7, tasks.Item8).GetAwaiter(); + } + + + public static UniTask.Awaiter GetAwaiter(this (UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6, UniTask task7, UniTask task8, UniTask task9) tasks) + { + return UniTask.WhenAll(tasks.Item1, tasks.Item2, tasks.Item3, tasks.Item4, tasks.Item5, tasks.Item6, tasks.Item7, tasks.Item8, tasks.Item9).GetAwaiter(); + } + + + public static UniTask.Awaiter GetAwaiter(this (UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6, UniTask task7, UniTask task8, UniTask task9, UniTask task10) tasks) + { + return UniTask.WhenAll(tasks.Item1, tasks.Item2, tasks.Item3, tasks.Item4, tasks.Item5, tasks.Item6, tasks.Item7, tasks.Item8, tasks.Item9, tasks.Item10).GetAwaiter(); + } + + + public static UniTask.Awaiter GetAwaiter(this (UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6, UniTask task7, UniTask task8, UniTask task9, UniTask task10, UniTask task11) tasks) + { + return UniTask.WhenAll(tasks.Item1, tasks.Item2, tasks.Item3, tasks.Item4, tasks.Item5, tasks.Item6, tasks.Item7, tasks.Item8, tasks.Item9, tasks.Item10, tasks.Item11).GetAwaiter(); + } + + + public static UniTask.Awaiter GetAwaiter(this (UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6, UniTask task7, UniTask task8, UniTask task9, UniTask task10, UniTask task11, UniTask task12) tasks) + { + return UniTask.WhenAll(tasks.Item1, tasks.Item2, tasks.Item3, tasks.Item4, tasks.Item5, tasks.Item6, tasks.Item7, tasks.Item8, tasks.Item9, tasks.Item10, tasks.Item11, tasks.Item12).GetAwaiter(); + } + + + public static UniTask.Awaiter GetAwaiter(this (UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6, UniTask task7, UniTask task8, UniTask task9, UniTask task10, UniTask task11, UniTask task12, UniTask task13) tasks) + { + return UniTask.WhenAll(tasks.Item1, tasks.Item2, tasks.Item3, tasks.Item4, tasks.Item5, tasks.Item6, tasks.Item7, tasks.Item8, tasks.Item9, tasks.Item10, tasks.Item11, tasks.Item12, tasks.Item13).GetAwaiter(); + } + + + public static UniTask.Awaiter GetAwaiter(this (UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6, UniTask task7, UniTask task8, UniTask task9, UniTask task10, UniTask task11, UniTask task12, UniTask task13, UniTask task14) tasks) + { + return UniTask.WhenAll(tasks.Item1, tasks.Item2, tasks.Item3, tasks.Item4, tasks.Item5, tasks.Item6, tasks.Item7, tasks.Item8, tasks.Item9, tasks.Item10, tasks.Item11, tasks.Item12, tasks.Item13, tasks.Item14).GetAwaiter(); + } + + + public static UniTask.Awaiter GetAwaiter(this (UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6, UniTask task7, UniTask task8, UniTask task9, UniTask task10, UniTask task11, UniTask task12, UniTask task13, UniTask task14, UniTask task15) tasks) + { + return UniTask.WhenAll(tasks.Item1, tasks.Item2, tasks.Item3, tasks.Item4, tasks.Item5, tasks.Item6, tasks.Item7, tasks.Item8, tasks.Item9, tasks.Item10, tasks.Item11, tasks.Item12, tasks.Item13, tasks.Item14, tasks.Item15).GetAwaiter(); + } + + } -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/Assets/UniRx.Async/UniTaskExtensions.Shorthand.cs.meta b/Assets/UniRx.Async/UniTaskExtensions.Shorthand.cs.meta deleted file mode 100644 index e2dcc14..0000000 --- a/Assets/UniRx.Async/UniTaskExtensions.Shorthand.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 4b4ff020f73dc6d4b8ebd4760d61fb43 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/UniRx.Async/UniTaskExtensions.Shorthand.tt b/Assets/UniRx.Async/UniTaskExtensions.Shorthand.tt new file mode 100644 index 0000000..ecc0767 --- /dev/null +++ b/Assets/UniRx.Async/UniTaskExtensions.Shorthand.tt @@ -0,0 +1,63 @@ +<#@ template debug="false" hostspecific="false" language="C#" #> +<#@ assembly name="System.Core" #> +<#@ import namespace="System.Linq" #> +<#@ import namespace="System.Text" #> +<#@ import namespace="System.Collections.Generic" #> +<#@ output extension=".cs" #> +#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member +using System.Collections.Generic; + +namespace UniRx.Async +{ + public static partial class UniTaskExtensions + { + // shorthand of WhenAll + + public static UniTask.Awaiter GetAwaiter(this UniTask[] tasks) + { + return UniTask.WhenAll(tasks).GetAwaiter(); + } + + public static UniTask.Awaiter GetAwaiter(this IEnumerable tasks) + { + return UniTask.WhenAll(tasks).GetAwaiter(); + } + + public static UniTask.Awaiter GetAwaiter(this UniTask[] tasks) + { + return UniTask.WhenAll(tasks).GetAwaiter(); + } + + public static UniTask.Awaiter GetAwaiter(this IEnumerable> tasks) + { + return UniTask.WhenAll(tasks).GetAwaiter(); + } + +<# for(var i = 2; i <= 15; i++ ) { + var range = Enumerable.Range(1, i); + var t = string.Join(", ", range.Select(x => "T" + x)); + var args = string.Join(", ", range.Select(x => $"UniTask task{x}")); + var titems = string.Join(", ", range.Select(x => $"tasks.Item{x}")); +#> + public static UniTask<(<#= t #>)>.Awaiter GetAwaiter<<#= t #>>(this (<#= args #>) tasks) + { + return UniTask.WhenAll(<#= titems #>).GetAwaiter(); + } + +<# } #> + +<# for(var i = 2; i <= 15; i++ ) { + var range = Enumerable.Range(1, i); + var args = string.Join(", ", range.Select(x => $"UniTask task{x}")); + var titems = string.Join(", ", range.Select(x => $"tasks.Item{x}")); +#> + + public static UniTask.Awaiter GetAwaiter(this (<#= args #>) tasks) + { + return UniTask.WhenAll(<#= titems #>).GetAwaiter(); + } + +<# } #> + + } +} \ No newline at end of file diff --git a/Assets/UniRx.Async/UniTaskExtensions.cs b/Assets/UniRx.Async/UniTaskExtensions.cs index 6115478..9642af1 100644 --- a/Assets/UniRx.Async/UniTaskExtensions.cs +++ b/Assets/UniRx.Async/UniTaskExtensions.cs @@ -26,13 +26,13 @@ namespace UniRx.Async switch (x.Status) { case TaskStatus.Canceled: - p.SetCanceled(); + p.TrySetCanceled(); break; case TaskStatus.Faulted: - p.SetException(x.Exception); + p.TrySetException(x.Exception); break; case TaskStatus.RanToCompletion: - p.SetResult(x.Result); + p.TrySetResult(x.Result); break; default: throw new NotSupportedException(); @@ -56,13 +56,13 @@ namespace UniRx.Async switch (x.Status) { case TaskStatus.Canceled: - p.SetCanceled(); + p.TrySetCanceled(); break; case TaskStatus.Faulted: - p.SetException(x.Exception); + p.TrySetException(x.Exception); break; case TaskStatus.RanToCompletion: - p.SetResult(); + p.TrySetResult(); break; default: throw new NotSupportedException(); @@ -190,23 +190,26 @@ namespace UniRx.Async return new ToCoroutineEnumerator(task, exceptionHandler); } - public static UniTask Timeout(this UniTask task, TimeSpan timeout, bool ignoreTimeScale = true, PlayerLoopTiming timeoutCheckTiming = PlayerLoopTiming.Update, CancellationTokenSource taskCancellationTokenSource = null) + public static async UniTask Timeout(this UniTask task, TimeSpan timeout, bool ignoreTimeScale = true, PlayerLoopTiming timeoutCheckTiming = PlayerLoopTiming.Update, CancellationTokenSource taskCancellationTokenSource = null) { - return Timeout(task.AsAsyncUnitUniTask(), timeout, ignoreTimeScale, timeoutCheckTiming, taskCancellationTokenSource); - } - - // TODO: require UniTask2.Delay, WhenAny, etc... - - public static async UniTask Timeout(this UniTask task, TimeSpan timeout, bool ignoreTimeScale = true, PlayerLoopTiming timeoutCheckTiming = PlayerLoopTiming.Update, CancellationTokenSource taskCancellationTokenSource = null) - { - // left, right both suppress operation canceled exception. - var delayCancellationTokenSource = new CancellationTokenSource(); - var timeoutTask = UniTask.Delay(timeout, ignoreTimeScale, timeoutCheckTiming).SuppressCancellationThrow(); + var timeoutTask = UniTask.Delay(timeout, ignoreTimeScale, timeoutCheckTiming, delayCancellationTokenSource.Token).SuppressCancellationThrow(); - var (hasValue, value) = await UniTask.WhenAny(task.SuppressCancellationThrow(), timeoutTask); + int winArgIndex; + bool taskResultIsCanceled; + try + { + (winArgIndex, taskResultIsCanceled, _) = await UniTask.WhenAny(task.SuppressCancellationThrow(), timeoutTask); + } + catch + { + delayCancellationTokenSource.Cancel(); + delayCancellationTokenSource.Dispose(); + throw; + } - if (!hasValue) + // timeout + if (winArgIndex == 1) { if (taskCancellationTokenSource != null) { @@ -222,37 +225,32 @@ namespace UniRx.Async delayCancellationTokenSource.Dispose(); } - if (value.IsCanceled) + if (taskResultIsCanceled) { Error.ThrowOperationCanceledException(); } - - return value.Result; } - /// - /// Timeout with suppress OperationCanceledException. Returns (bool, IsCacneled). - /// - public static async UniTask TimeoutWithoutException(this UniTask task, TimeSpan timeout, bool ignoreTimeScale = true, PlayerLoopTiming timeoutCheckTiming = PlayerLoopTiming.Update, CancellationTokenSource taskCancellationTokenSource = null) + public static async UniTask Timeout(this UniTask task, TimeSpan timeout, bool ignoreTimeScale = true, PlayerLoopTiming timeoutCheckTiming = PlayerLoopTiming.Update, CancellationTokenSource taskCancellationTokenSource = null) { - var v = await TimeoutWithoutException(task.AsAsyncUnitUniTask(), timeout, ignoreTimeScale, timeoutCheckTiming, taskCancellationTokenSource); - return v.IsTimeout; - } - - - /// - /// Timeout with suppress OperationCanceledException. Returns (bool IsTimeout, T Result). - /// - public static async UniTask<(bool IsTimeout, T Result)> TimeoutWithoutException(this UniTask task, TimeSpan timeout, bool ignoreTimeScale = true, PlayerLoopTiming timeoutCheckTiming = PlayerLoopTiming.Update, CancellationTokenSource taskCancellationTokenSource = null) - { - // left, right both suppress operation canceled exception. - var delayCancellationTokenSource = new CancellationTokenSource(); - var timeoutTask = UniTask.Delay(timeout, ignoreTimeScale, timeoutCheckTiming).SuppressCancellationThrow(); + var timeoutTask = UniTask.Delay(timeout, ignoreTimeScale, timeoutCheckTiming, delayCancellationTokenSource.Token).SuppressCancellationThrow(); - var (hasValue, value) = await UniTask.WhenAny(task.SuppressCancellationThrow(), timeoutTask); + int winArgIndex; + (bool IsCanceled, T Result) taskResult; + try + { + (winArgIndex, taskResult, _) = await UniTask.WhenAny(task.SuppressCancellationThrow(), timeoutTask); + } + catch + { + delayCancellationTokenSource.Cancel(); + delayCancellationTokenSource.Dispose(); + throw; + } - if (!hasValue) + // timeout + if (winArgIndex == 1) { if (taskCancellationTokenSource != null) { @@ -260,7 +258,7 @@ namespace UniRx.Async taskCancellationTokenSource.Dispose(); } - return (true, default(T)); + throw new TimeoutException("Exceed Timeout:" + timeout); } else { @@ -268,24 +266,142 @@ namespace UniRx.Async delayCancellationTokenSource.Dispose(); } - if (value.IsCanceled) + if (taskResult.IsCanceled) { Error.ThrowOperationCanceledException(); } - return (false, value.Result); + return taskResult.Result; + } + + /// + /// Timeout with suppress OperationCanceledException. Returns (bool, IsCacneled). + /// + public static async UniTask TimeoutWithoutException(this UniTask task, TimeSpan timeout, bool ignoreTimeScale = true, PlayerLoopTiming timeoutCheckTiming = PlayerLoopTiming.Update, CancellationTokenSource taskCancellationTokenSource = null) + { + var delayCancellationTokenSource = new CancellationTokenSource(); + var timeoutTask = UniTask.Delay(timeout, ignoreTimeScale, timeoutCheckTiming, delayCancellationTokenSource.Token).SuppressCancellationThrow(); + + int winArgIndex; + bool taskResultIsCanceled; + try + { + (winArgIndex, taskResultIsCanceled, _) = await UniTask.WhenAny(task.SuppressCancellationThrow(), timeoutTask); + } + catch + { + delayCancellationTokenSource.Cancel(); + delayCancellationTokenSource.Dispose(); + return true; + } + + // timeout + if (winArgIndex == 1) + { + if (taskCancellationTokenSource != null) + { + taskCancellationTokenSource.Cancel(); + taskCancellationTokenSource.Dispose(); + } + + throw new TimeoutException("Exceed Timeout:" + timeout); + } + else + { + delayCancellationTokenSource.Cancel(); + delayCancellationTokenSource.Dispose(); + } + + if (taskResultIsCanceled) + { + Error.ThrowOperationCanceledException(); + } + + return false; + } + + /// + /// Timeout with suppress OperationCanceledException. Returns (bool IsTimeout, T Result). + /// + public static async UniTask<(bool IsTimeout, T Result)> TimeoutWithoutException(this UniTask task, TimeSpan timeout, bool ignoreTimeScale = true, PlayerLoopTiming timeoutCheckTiming = PlayerLoopTiming.Update, CancellationTokenSource taskCancellationTokenSource = null) + { + var delayCancellationTokenSource = new CancellationTokenSource(); + var timeoutTask = UniTask.Delay(timeout, ignoreTimeScale, timeoutCheckTiming, delayCancellationTokenSource.Token).SuppressCancellationThrow(); + + int winArgIndex; + (bool IsCanceled, T Result) taskResult; + try + { + (winArgIndex, taskResult, _) = await UniTask.WhenAny(task.SuppressCancellationThrow(), timeoutTask); + } + catch + { + delayCancellationTokenSource.Cancel(); + delayCancellationTokenSource.Dispose(); + return (true, default); + } + + // timeout + if (winArgIndex == 1) + { + if (taskCancellationTokenSource != null) + { + taskCancellationTokenSource.Cancel(); + taskCancellationTokenSource.Dispose(); + } + + throw new TimeoutException("Exceed Timeout:" + timeout); + } + else + { + delayCancellationTokenSource.Cancel(); + delayCancellationTokenSource.Dispose(); + } + + if (taskResult.IsCanceled) + { + Error.ThrowOperationCanceledException(); + } + + return (false, taskResult.Result); } public static void Forget(this UniTask task) { - ForgetCore(task).Forget(); + var awaiter = task.GetAwaiter(); + if (awaiter.IsCompleted) + { + try + { + awaiter.GetResult(); + } + catch (Exception ex) + { + UniTaskScheduler.PublishUnobservedTaskException(ex); + } + } + + awaiter.SourceOnCompleted(state => + { + using (var t = (StateTuple)state) + { + try + { + t.Item1.GetResult(); + } + catch (Exception ex) + { + UniTaskScheduler.PublishUnobservedTaskException(ex); + } + } + }, StateTuple.Create(awaiter)); } public static void Forget(this UniTask task, Action exceptionHandler, bool handleExceptionOnMainThread = true) { if (exceptionHandler == null) { - ForgetCore(task).Forget(); + Forget(task); } else { @@ -293,12 +409,6 @@ namespace UniRx.Async } } - // UniTask to UniTaskVoid - static async UniTaskVoid ForgetCore(UniTask task) - { - await task; - } - static async UniTaskVoid ForgetCoreWithCatch(UniTask task, Action exceptionHandler, bool handleExceptionOnMainThread) { try @@ -324,14 +434,40 @@ namespace UniRx.Async public static void Forget(this UniTask task) { - ForgetCore(task).Forget(); + var awaiter = task.GetAwaiter(); + if (awaiter.IsCompleted) + { + try + { + awaiter.GetResult(); + } + catch (Exception ex) + { + UniTaskScheduler.PublishUnobservedTaskException(ex); + } + } + + awaiter.SourceOnCompleted(state => + { + using (var t = (StateTuple.Awaiter>)state) + { + try + { + t.Item1.GetResult(); + } + catch (Exception ex) + { + UniTaskScheduler.PublishUnobservedTaskException(ex); + } + } + }, StateTuple.Create(awaiter)); } public static void Forget(this UniTask task, Action exceptionHandler, bool handleExceptionOnMainThread = true) { if (exceptionHandler == null) { - ForgetCore(task).Forget(); + task.Forget(); } else { @@ -339,12 +475,6 @@ namespace UniRx.Async } } - // UniTask to UniTaskVoid - static async UniTaskVoid ForgetCore(UniTask task) - { - await task; - } - static async UniTaskVoid ForgetCoreWithCatch(UniTask task, Action exceptionHandler, bool handleExceptionOnMainThread) { try diff --git a/Assets/UniRx.Async/UniTaskObservableExtensions.cs b/Assets/UniRx.Async/UniTaskObservableExtensions.cs index 2c5dd49..2276bd4 100644 --- a/Assets/UniRx.Async/UniTaskObservableExtensions.cs +++ b/Assets/UniRx.Async/UniTaskObservableExtensions.cs @@ -33,7 +33,7 @@ namespace UniRx.Async public static IObservable ToObservable(this UniTask task) { - if (task.IsCompleted) + if (task.Status.IsCompleted()) { try { @@ -55,7 +55,7 @@ namespace UniRx.Async /// public static IObservable ToObservable(this UniTask task) { - if (task.IsCompleted) + if (task.Status.IsCompleted()) { try { diff --git a/Assets/UniRx.Async/UnityAsyncExtensions.MonoBehaviour.cs b/Assets/UniRx.Async/UnityAsyncExtensions.MonoBehaviour.cs new file mode 100644 index 0000000..82e26c8 --- /dev/null +++ b/Assets/UniRx.Async/UnityAsyncExtensions.MonoBehaviour.cs @@ -0,0 +1,14 @@ +using System; +using System.Threading; + +namespace UniRx.Async +{ + public static partial class UnityAsyncExtensions + { + public static void StartAsyncCoroutine(this UnityEngine.MonoBehaviour monoBehaviour, Func asyncCoroutine) + { + var token = monoBehaviour.GetCancellationTokenOnDestroy(); + asyncCoroutine(token).Forget(); + } + } +} \ No newline at end of file diff --git a/Assets/UniRx.Async/UnityAsyncExtensions.cs b/Assets/UniRx.Async/UnityAsyncExtensions.cs index cec9a2f..285eda5 100644 --- a/Assets/UniRx.Async/UnityAsyncExtensions.cs +++ b/Assets/UniRx.Async/UnityAsyncExtensions.cs @@ -2,6 +2,7 @@ #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member using System; +using System.Runtime.CompilerServices; using System.Threading; using UniRx.Async.Internal; using UnityEngine; @@ -183,11 +184,11 @@ namespace UniRx.Async #endif - public struct AsyncOperationAwaiter : IAwaiter + public struct AsyncOperationAwaiter : ICriticalNotifyCompletion { AsyncOperation asyncOperation; Action continuationAction; - UniTaskStatus status; + // UniTaskStatus status; public AsyncOperationAwaiter(AsyncOperation asyncOperation) { @@ -196,13 +197,12 @@ namespace UniRx.Async this.continuationAction = null; } - public bool IsCompleted => status.IsCompleted(); - public UniTaskStatus Status => status; + public bool IsCompleted => asyncOperation.isDone; public void GetResult() { - if (status == UniTaskStatus.Succeeded) return; - + //*/ if (status == UniTaskStatus.Succeeded) return; + /* if (status == UniTaskStatus.Pending) { // first timing of call @@ -215,6 +215,7 @@ namespace UniRx.Async Error.ThrowNotYetCompleted(); } } + */ if (continuationAction != null) { @@ -236,7 +237,7 @@ namespace UniRx.Async public void UnsafeOnCompleted(Action continuation) { Error.ThrowWhenContinuationIsAlreadyRegistered(continuationAction); - continuationAction = continuation.AsFuncOfT(); + continuationAction = continuation.AsFuncOfT(); // allocate delegate. asyncOperation.completed += continuationAction; } }