Esempio n. 1
0
 public static async AwaitableCoroutine WaitAll(AwaitableCoroutineBase c1, AwaitableCoroutineBase c2, AwaitableCoroutineBase c3, AwaitableCoroutineBase c4, AwaitableCoroutineBase c5, AwaitableCoroutineBase c6)
 {
     while (!(c1.IsCompleted && c2.IsCompleted && c3.IsCompleted && c4.IsCompleted && c5.IsCompleted && c6.IsCompleted))
     {
         if (c1.IsCanceled)
         {
             AwaitableCoroutine.ThrowChildCancel <AwaitableCoroutineBase>(c1);
         }
         if (c2.IsCanceled)
         {
             AwaitableCoroutine.ThrowChildCancel <AwaitableCoroutineBase>(c2);
         }
         if (c3.IsCanceled)
         {
             AwaitableCoroutine.ThrowChildCancel <AwaitableCoroutineBase>(c3);
         }
         if (c4.IsCanceled)
         {
             AwaitableCoroutine.ThrowChildCancel <AwaitableCoroutineBase>(c4);
         }
         if (c5.IsCanceled)
         {
             AwaitableCoroutine.ThrowChildCancel <AwaitableCoroutineBase>(c5);
         }
         if (c6.IsCanceled)
         {
             AwaitableCoroutine.ThrowChildCancel <AwaitableCoroutineBase>(c6);
         }
         await Yield();
     }
 }
 public static async AwaitableCoroutine WaitAny(AwaitableCoroutineBase c1, AwaitableCoroutineBase c2)
 {
     while (!(c1.IsCompleted || c2.IsCompleted))
     {
         if (c1.IsCanceled && c2.IsCanceled)
         {
             AwaitableCoroutine.ThrowChildrenCancel <AwaitableCoroutineBase>(new AwaitableCoroutineBase[] { c1, c2 });
         }
         await Yield();
     }
 }
 public static async AwaitableCoroutine WaitAny(AwaitableCoroutineBase c1, AwaitableCoroutineBase c2, AwaitableCoroutineBase c3, AwaitableCoroutineBase c4, AwaitableCoroutineBase c5, AwaitableCoroutineBase c6, AwaitableCoroutineBase c7)
 {
     while (!(c1.IsCompleted || c2.IsCompleted || c3.IsCompleted || c4.IsCompleted || c5.IsCompleted || c6.IsCompleted || c7.IsCompleted))
     {
         if (c1.IsCanceled && c2.IsCanceled && c3.IsCanceled && c4.IsCanceled && c5.IsCanceled && c6.IsCanceled && c7.IsCanceled)
         {
             AwaitableCoroutine.ThrowChildrenCancel <AwaitableCoroutineBase>(new AwaitableCoroutineBase[] { c1, c2, c3, c4, c5, c6, c7 });
         }
         await Yield();
     }
 }
Esempio n. 4
0
        public static async AwaitableCoroutine <T> SelectTo <T>(this AwaitableCoroutineBase coroutine, T result)
        {
            while (!coroutine.IsCompleted)
            {
                if (coroutine.IsCanceled)
                {
                    AwaitableCoroutine.ThrowChildCancel <AwaitableCoroutineBase>(coroutine);
                }
                await AwaitableCoroutine.Yield();
            }

            return(result);
        }
Esempio n. 5
0
 public static async AwaitableCoroutine WaitAll(AwaitableCoroutineBase c1, AwaitableCoroutineBase c2)
 {
     while (!(c1.IsCompleted && c2.IsCompleted))
     {
         if (c1.IsCanceled)
         {
             AwaitableCoroutine.ThrowChildCancel <AwaitableCoroutineBase>(c1);
         }
         if (c2.IsCanceled)
         {
             AwaitableCoroutine.ThrowChildCancel <AwaitableCoroutineBase>(c2);
         }
         await Yield();
     }
 }
        public static async AwaitableCoroutine UntilCompleted <T>(this AwaitableCoroutineBase coroutine, Func <AwaitableCoroutine <T> > action)
        {
            if (coroutine is null)
            {
                ThrowHelper.ArgNull(nameof(coroutine));
            }

            if (action is null)
            {
                ThrowHelper.ArgNull(nameof(action));
            }

            while (!coroutine.IsCompleted)
            {
                if (coroutine.IsCanceled)
                {
                    AwaitableCoroutine.ThrowChildCancel <AwaitableCoroutineBase>(coroutine);
                }
                _ = await action.Invoke();
            }
        }
        public static async AwaitableCoroutine UntilCompleted(this AwaitableCoroutineBase coroutine, Func <AwaitableCoroutine> createCoroutine)
        {
            if (coroutine is null)
            {
                ThrowHelper.ArgNull(nameof(coroutine));
            }

            if (createCoroutine is null)
            {
                ThrowHelper.ArgNull(nameof(createCoroutine));
            }

            while (!coroutine.IsCompleted)
            {
                if (coroutine.IsCanceled)
                {
                    AwaitableCoroutine.ThrowChildCancel <AwaitableCoroutineBase>(coroutine);
                }
                await createCoroutine.Invoke();
            }
        }
 void ICoroutineRunner.OnRegistering(AwaitableCoroutineBase coroutine)
 {
     Internal.Logger.Log($"CoroutineRunner.Registering {coroutine.GetType().Name}");
     _coroutinesTmp.Add(coroutine);
     Count++;
 }