< Summary

Class:DCL.Helpers.TaskUtils
Assembly:UniTaskUtils
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Helpers/Utils/TaskUtils/TaskUtils.cs
Covered lines:9
Uncovered lines:8
Coverable lines:17
Total lines:73
Line coverage:52.9% (9 of 17)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Run()0%7.736063.64%
Run()0%42600%
RunThrottledCoroutine()0%330100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Helpers/Utils/TaskUtils/TaskUtils.cs

#LineLine coverage
 1using System;
 2using System.Collections;
 3using System.Threading;
 4using Cysharp.Threading.Tasks;
 5
 6namespace DCL.Helpers
 7{
 8    public static class TaskUtils
 9    {
 89210        private static BaseVariable<bool> multithreading => DataStore.i.performance.multithreading;
 11        public static async UniTask Run(Action action, CancellationToken cancellationToken = default, bool returnToMainT
 12        {
 88613            cancellationToken.ThrowIfCancellationRequested();
 14
 88615            if (multithreading.Get())
 16            {
 017                await UniTask.RunOnThreadPool(action, returnToMainThread, cancellationToken);
 018            }
 19            else
 20            {
 265821                await UniTask.Yield(cancellationToken);
 88422                action();
 23            }
 88424        }
 25
 26        public static async UniTask Run(Func<UniTask> action, CancellationToken cancellationToken = default, bool return
 27        {
 028            cancellationToken.ThrowIfCancellationRequested();
 29
 030            if (multithreading.Get())
 31            {
 032                await UniTask.RunOnThreadPool(action, returnToMainThread, cancellationToken);
 033            }
 34            else
 35            {
 036                await UniTask.Create(action).AttachExternalCancellation(cancellationToken);
 37            }
 038        }
 39
 40        public static async UniTask<T> Run<T>(Func<UniTask<T>> action, CancellationToken cancellationToken = default, bo
 41        {
 42            cancellationToken.ThrowIfCancellationRequested();
 43
 44            if (multithreading.Get())
 45            {
 46                return await UniTask.RunOnThreadPool(action, returnToMainThread, cancellationToken);
 47            }
 48
 49            return await UniTask.Create(action).AttachExternalCancellation(cancellationToken);
 50        }
 51
 52        public static async UniTask<T> Run<T>(Func<T> action, CancellationToken cancellationToken = default, bool return
 53        {
 54            cancellationToken.ThrowIfCancellationRequested();
 55
 56            if (multithreading.Get())
 57            {
 58                return await UniTask.RunOnThreadPool(action, returnToMainThread, cancellationToken);
 59            }
 60
 61            await UniTask.Yield(cancellationToken);
 62
 63            return action();
 64        }
 65
 66        public static async UniTask RunThrottledCoroutine(IEnumerator enumerator, Action<Exception> onFail, Func<double,
 67        {
 10868            IEnumerator routine = DCLCoroutineRunner.Run(enumerator, onFail, timeBudget);
 32369            await routine.ToUniTask(CoroutineStarter.instance);
 10770        }
 71
 72    }
 73}