public static IUniTaskSource <T> Create(AsyncReactiveProperty <T> parent, CancellationToken cancellationToken, out short token) { if (cancellationToken.IsCancellationRequested) { return(AutoResetUniTaskCompletionSource <T> .CreateFromCanceled(cancellationToken, out token)); } if (!pool.TryPop(out var result)) { result = new WaitAsyncSource(); } result.parent = parent; result.cancellationToken = cancellationToken; if (cancellationToken.CanBeCanceled) { result.cancellationTokenRegistration = cancellationToken.RegisterWithoutCaptureExecutionContext(cancellationCallback, result); } result.parent.triggerEvent.Add(result); TaskTracker.TrackActiveTask(result, 3); token = result.core.Version; return(result); }
bool TryReturn() { TaskTracker.RemoveTracking(this); core.Reset(); cancellationTokenRegistration.Dispose(); cancellationTokenRegistration = default; parent.triggerEvent.Remove(this); parent = null; cancellationToken = default; return(pool.TryPush(this)); }
public Enumerator(AsyncReactiveProperty <T> parent, CancellationToken cancellationToken, bool publishCurrentValue) { this.parent = parent; this.cancellationToken = cancellationToken; this.firstCall = publishCurrentValue; parent.triggerEvent.Add(this); TaskTracker.TrackActiveTask(this, 3); if (cancellationToken.CanBeCanceled) { cancellationTokenRegistration = cancellationToken.RegisterWithoutCaptureExecutionContext(cancellationCallback, this); } }
public static void BindTo <T>(this AsyncReactiveProperty <T> source, TMP_Text text, bool rebindOnError = true) { BindToCore(source, text, text.GetCancellationTokenOnDestroy(), rebindOnError).Forget(); }
public WithoutCurrentEnumerable(AsyncReactiveProperty <T> parent) { this.parent = parent; }