void ISchedulable.Schedule(TaskScheduler scheduler, IFuture future) { _Future = future; _Scheduler = scheduler; _Future.RegisterOnDispose(this.OnDisposed); QueueStep(); }
void ISchedulable.Schedule(TaskScheduler scheduler, IFuture future) { if (_Schedulables == null) { throw new InvalidOperationException(); } else if (_Schedulables.Length == 0) { future.Complete(); return; } for (int i = 0; i < _Schedulables.Length; i++) { var s = _Schedulables[i]; if (s != null) { _Futures[i] = scheduler.Start(s, TaskExecutionPolicy.RunWhileFutureLives); } } _Schedulables = null; _ResultFuture = future; _WaitFuture = Future.WaitForAll(_Futures); _WaitFuture.RegisterOnComplete(HandleResult); _WaitFuture.RegisterOnDispose(HandleDisposed); }
public void OnCompleted(Action continuation) { var oc = Registration.OnComplete(continuation); Future.RegisterOnComplete(oc); Future.RegisterOnDispose((f) => oc(f)); }
void ISchedulable.Schedule(TaskScheduler scheduler, IFuture future) { if (future == null) throw new ArgumentNullException("future"); _Future = future; _Scheduler = scheduler; _Future.RegisterOnDispose(this.OnDisposed); QueueStep(); }
void ISchedulable.Schedule(TaskScheduler scheduler, IFuture future) { if (future == null) { throw new ArgumentNullException("future"); } _Future = future; _Scheduler = scheduler; _Future.RegisterOnDispose(this.OnDisposed); QueueStep(); }
void ISchedulable.Schedule(TaskScheduler scheduler, IFuture future) { _Future = scheduler.Start(_Task, TaskExecutionPolicy.RunAsBackgroundTask); _Future.RegisterOnComplete((f) => { object r; Exception e; f.GetResult(out r, out e); future.Complete(r); }); _Future.RegisterOnDispose(future.Dispose); }
public static void BindFuture(this tTask task, IFuture future) { task.GetAwaiter().OnCompleted(() => { // FIXME: ExceptionDispatchInfo? if (task.IsFaulted) { future.Fail(task.Exception.InnerExceptions.Count == 1 ? task.Exception.InnerException : task.Exception); } else { future.Complete(); } }); future.RegisterOnDispose((_) => { task.TryCancelScope(); }); }
protected void Start() { _Thunk = new SchedulableGeneratorThunk(_Task); _Thunk.OnNextValue = OnNextValue; _SequenceFuture = _Scheduler.Start(_Thunk, TaskExecutionPolicy.RunWhileFutureLives); _SequenceFuture.RegisterOnDispose((f) => { Resume(); Dispose(); }); _SequenceFuture.RegisterOnComplete((f) => { if (f.Failed) { Fail(f.Error); } else { Resume(); } }); }
public static void BindFuture(this tTask task, IFuture future) { if (task.IsCompleted && !task.IsFaulted) { future.Complete(); return; } task.ConfigureAwait(false).GetAwaiter().OnCompleted(() => { // FIXME: ExceptionDispatchInfo? if (task.IsFaulted) { future.Fail(task.Exception.InnerExceptions.Count == 1 ? task.Exception.InnerException : task.Exception); } else { future.Complete(); } }); future.RegisterOnDispose(CancelScopeForTask, task); }
void SetWakeConditionAndSubscribe(IFuture f, bool discardingResult) { SetWakeCondition(f, discardingResult); f.RegisterOnComplete(_QueueStepOnComplete); f.RegisterOnDispose(_QueueStepOnDispose); }
public void RegisterOnDispose(OnDispose handler) { _SendFuture.RegisterOnDispose(handler); }