< Summary

Class:DCL.CoroutineUtils
Assembly:CoroutineHelpers
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Helpers/CoroutineHelpers/CoroutineUtils.cs
Covered lines:0
Uncovered lines:10
Coverable lines:10
Total lines:65
Line coverage:0% (0 of 10)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
StartThrottledCoroutine(...)0%2100%
StartThrowingCoroutine(...)0%2100%
WaitForAllIEnumerators()0%30500%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Helpers/CoroutineHelpers/CoroutineUtils.cs

#LineLine coverage
 1using System;
 2using System.Collections;
 3using System.Collections.Generic;
 4using UnityEngine;
 5
 6namespace DCL
 7{
 8    public static class CoroutineUtils
 9    {
 10        /// <summary>
 11        /// Start a coroutine that might throw an exception. Call the callback with the exception if it
 12        /// does or null if it finishes without throwing an exception.
 13        /// </summary>
 14        /// <param name="monoBehaviour">MonoBehaviour to start the coroutine on</param>
 15        /// <param name="enumerator">Iterator function to run as the coroutine</param>
 16        /// <param name="onException">Callback to call when the coroutine has thrown an exception or finished.
 17        /// The thrown exception or null is passed as the parameter.</param>
 18        /// <returns>The started coroutine</returns>
 19        public static Coroutine StartThrottledCoroutine(
 20            this MonoBehaviour monoBehaviour,
 21            IEnumerator enumerator,
 22            Action<Exception> onException,
 23            Func<double, bool> timeBudgetCounter
 24        )
 25        {
 026            return CoroutineStarter.Start(DCLCoroutineRunner.Run(enumerator, onException, timeBudgetCounter));
 27        }
 28
 29
 30        /// <summary>
 31        /// Start a coroutine that might throw an exception. Call the callback with the exception if it
 32        /// does or null if it finishes without throwing an exception.
 33        /// </summary>
 34        /// <param name="monoBehaviour">MonoBehaviour to start the coroutine on</param>
 35        /// <param name="enumerator">Iterator function to run as the coroutine</param>
 36        /// <param name="onException">Callback to call when the coroutine has thrown an exception or finished.
 37        /// The thrown exception or null is passed as the parameter.</param>
 38        /// <returns>The started coroutine</returns>
 39        public static Coroutine StartThrowingCoroutine(
 40            this MonoBehaviour monoBehaviour,
 41            IEnumerator enumerator,
 42            Action<Exception> onException
 43        )
 44        {
 045            return CoroutineStarter.Start(DCLCoroutineRunner.Run(enumerator, onException, null));
 46        }
 47
 48
 49        public static IEnumerator WaitForAllIEnumerators(params IEnumerator[] coroutines)
 50        {
 051            List<Coroutine> coroutineGroup = new List<Coroutine>();
 052            for (int i = 0; i < coroutines.Length; i++)
 53            {
 054                coroutineGroup.Add(CoroutineStarter.Start(coroutines[i]));
 55            }
 56
 057            int coroutineGroupCount = coroutineGroup.Count;
 058            for (int index = 0; index < coroutineGroupCount; index++)
 59            {
 060                var coroutine = coroutineGroup[index];
 061                yield return coroutine;
 62            }
 063        }
 64    }
 65}