public static ArgNull ( string paramName ) : void | ||
paramName | string | |
return | void |
internal void AddOnCanceled(Action onCanceled) { if (onCanceled is null) { ThrowHelper.ArgNull(nameof(onCanceled)); } if (IsCompleted) { ThrowHelper.InvalidOp("Coroutine is already completed"); } if (IsCanceled) { onCanceled.Invoke(); return; } var runner = ICoroutineRunner.GetContext(); if (Runner == runner) { OnCalceled += onCanceled; } else { OnCalceled += () => runner.Context(onCanceled); } }
public static T OnUpdating <T>(this T coroutine, Action onUpdating) where T : AwaitableCoroutineBase { if (coroutine is null) { ThrowHelper.ArgNull(nameof(coroutine)); } if (onUpdating is null) { ThrowHelper.ArgNull(nameof(onUpdating)); } if (coroutine.IsCanceled) { ThrowHelper.InvalidOp("Coroutine is already canceled"); } if (coroutine.IsCompleted) { ThrowHelper.InvalidOp("Coroutine is already completed"); } coroutine.OnUpdating += onUpdating; return(coroutine); }
internal void ContinueWith(Action action) { if (action is null) { ThrowHelper.ArgNull(nameof(action)); } if (IsCanceled) { ThrowHelper.InvalidOp("Coroutine is already canceled"); } if (IsCompleted) { action.Invoke(); return; } var runner = ICoroutineRunner.GetContext(); if (Runner == runner) { OnCompleted += action; } else { OnCompleted += () => runner.Context(action); } }
public static async AwaitableCoroutine AndThen(this AwaitableCoroutine coroutine, Func <AwaitableCoroutine> thunk) { if (thunk is null) { ThrowHelper.ArgNull(nameof(thunk)); } await coroutine; await thunk(); }
public static async AwaitableCoroutine <U> AndThen <T, U>(this AwaitableCoroutine <T> coroutine, Func <T, AwaitableCoroutine <U> > thunk) { if (thunk is null) { ThrowHelper.ArgNull(nameof(thunk)); } var res = await coroutine; return(await thunk(res)); }
public static async AwaitableCoroutine <T> AndThen <T>(this AwaitableCoroutine coroutine, Func <AwaitableCoroutine <T> > thunk) { if (thunk is null) { ThrowHelper.ArgNull(nameof(thunk)); } await coroutine; return(await thunk()); }
public static async AwaitableCoroutine FromEnumerator(IEnumerator enumerator) { if (enumerator is null) { ThrowHelper.ArgNull(nameof(enumerator)); } while (enumerator.MoveNext()) { await Yield(); } }
public static async AwaitableCoroutine While(Func <bool> predicate) { if (predicate is null) { ThrowHelper.ArgNull(nameof(predicate)); } while (predicate()) { await Yield(); } }
public static T OnCompleted <T>(this T coroutine, Action onCompleted) where T : AwaitableCoroutineBase { if (coroutine is null) { ThrowHelper.ArgNull(nameof(coroutine)); } if (onCompleted is null) { ThrowHelper.ArgNull(nameof(onCompleted)); } coroutine.ContinueWith(onCompleted); return(coroutine); }
public static T OnCanceled <T>(this T coroutine, Action onCanceled) where T : AwaitableCoroutineBase { if (coroutine is null) { ThrowHelper.ArgNull(nameof(coroutine)); } if (onCanceled is null) { ThrowHelper.ArgNull(nameof(onCanceled)); } coroutine.AddOnCanceled(onCanceled); return(coroutine); }
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(); } }
public static async AwaitableCoroutine <U> Select <T, U>(this AwaitableCoroutine <T> coroutine, Func <T, U> thunk) { if (coroutine is null) { ThrowHelper.ArgNull(nameof(coroutine)); } if (thunk is null) { ThrowHelper.ArgNull(nameof(thunk)); } while (!coroutine.IsCompleted) { if (coroutine.IsCanceled) { AwaitableCoroutine.ThrowChildCancel <AwaitableCoroutineBase>(coroutine); } await AwaitableCoroutine.Yield(); } return(thunk(coroutine.Result)); }