Exemplo n.º 1
0
 public static IEnumerator ToCoroutine(this UniTask task, Action <Exception> exceptionHandler = null)
 {
     return(new ToCoroutineEnumerator(task, exceptionHandler));
 }
Exemplo n.º 2
0
 public WithCancellationSource(UniTask task, CancellationToken cancellationToken)
 {
     this.cancellationToken = cancellationToken;
     this.tokenRegistration = cancellationToken.RegisterWithoutCaptureExecutionContext(cancellationCallbackDelegate, this);
     RunTask(task).Forget();
 }
Exemplo n.º 3
0
 public static IEnumerator ToCoroutine <T>(this UniTask <T> task, Action <T> resultHandler = null, Action <Exception> exceptionHandler = null)
 {
     return(new ToCoroutineEnumerator <T>(task, resultHandler, exceptionHandler));
 }
Exemplo n.º 4
0
 public static AsyncLazy ToAsyncLazy(this UniTask task)
 {
     return(new AsyncLazy(task));
 }
Exemplo n.º 5
0
 public static AsyncLazy <T> ToAsyncLazy <T>(this UniTask <T> task)
 {
     return(new AsyncLazy <T>(task));
 }
 public static UniTask <T[]> .Awaiter GetAwaiter <T>(this IEnumerable <UniTask <T> > tasks)
 {
     return(UniTask.WhenAll(tasks).GetAwaiter());
 }
Exemplo n.º 7
0
 /// <summary>
 /// Same as UniTask.Yield(PlayerLoopTiming.FixedUpdate).
 /// </summary>
 public static YieldAwaitable WaitForFixedUpdate()
 {
     return(UniTask.Yield(PlayerLoopTiming.FixedUpdate));
 }
Exemplo n.º 8
0
 /// <summary>
 /// Same as UniTask.Yield(PlayerLoopTiming.LastPostLateUpdate).
 /// </summary>
 public static YieldAwaitable WaitForEndOfFrame()
 {
     return(UniTask.Yield(PlayerLoopTiming.LastPostLateUpdate));
 }
Exemplo n.º 9
0
 public UniTask ToUniTask()
 {
     return(UniTask.Yield(timing, CancellationToken.None));
 }
Exemplo n.º 10
0
 static CanceledUniTaskCache()
 {
     Task = new UniTask <T>(new CanceledResultSource <T>(CancellationToken.None), 0);
 }
Exemplo n.º 11
0
 /// <summary>
 /// Same as UniTask.Yield(PlayerLoopTiming.FixedUpdate, cancellationToken).
 /// </summary>
 public static UniTask WaitForFixedUpdate(CancellationToken cancellationToken)
 {
     return(UniTask.Yield(PlayerLoopTiming.FixedUpdate, cancellationToken));
 }
        public static void CancelAfterSlim(this CancellationTokenSource cts, TimeSpan delayTimeSpan, bool ignoreTimeScale = false, PlayerLoopTiming delayTiming = PlayerLoopTiming.Update)
        {
            var delay = UniTask.Delay(delayTimeSpan, ignoreTimeScale, delayTiming, cts.Token);

            CancelAfterCore(cts, delay).Forget();
        }
Exemplo n.º 13
0
        public static async UniTask WaitAsync(this JobHandle jobHandle, PlayerLoopTiming waitTiming)
        {
            await UniTask.Yield(waitTiming);

            jobHandle.Complete();
        }
        // shorthand of WhenAll

        public static UniTask.Awaiter GetAwaiter(this UniTask[] tasks)
        {
            return(UniTask.WhenAll(tasks).GetAwaiter());
        }
Exemplo n.º 15
0
 /// <summary>
 /// Timeout with suppress OperationCanceledException. Returns (bool IsTimeout, T Result).
 /// </summary>
 public static async UniTask <(bool IsTimeout, T Result)> TimeoutWithoutException <T>(this UniTask <T> task, TimeSpan timeout, DelayType delayType = DelayType.DeltaTime, PlayerLoopTiming timeoutCheckTiming = PlayerLoopTiming.Update, CancellationTokenSource taskCancellationTokenSource = null)
 {
Exemplo n.º 16
0
 /// <summary>
 /// Same as UniTask.Yield(PlayerLoopTiming.LastPostLateUpdate, cancellationToken).
 /// </summary>
 public static UniTask WaitForEndOfFrame(CancellationToken cancellationToken)
 {
     return(UniTask.Yield(PlayerLoopTiming.LastPostLateUpdate, cancellationToken));
 }
 public static bool IsCompleted(this Cysharp.Threading.Tasks.UniTask that) => that.GetAwaiter().IsCompleted;
 public static UniTask <T[]> .Awaiter GetAwaiter <T>(this UniTask <T>[] tasks)
 {
     return(UniTask.WhenAll(tasks).GetAwaiter());
 }