/// <summary> /// Creates a <see cref="IReactiveComputation{T}"/> from given source. /// This also creates a <see cref="RcRootSummary{T}"/> that internally represents the computation and its current result. /// The <see cref="IReactiveComputation{T}"/> is subscribed to the <see cref="RcRootSummary{T}"/> to be notified whenever its result changes. /// </summary> /// <typeparam name="T">Type of the result returned by the source</typeparam> /// <param name="computation">The actual computation, or source.</param> /// <returns></returns> public override ReactiveComputation <T> CreateReactiveComputation <T>(Func <Task <T> > computation) { var localKey = Guid.NewGuid(); var rc = new ReactiveComputation <T>(() => { OutsideSummaryWorker disposed; WorkerMap.TryRemove(localKey.ToString(), out disposed); disposed.Dispose(); }); var RcSummary = new RcRootSummary <T>(localKey, computation, rc); var scheduler = new OutsideReactiveScheduler(RcSummary); var worker = new OutsideSummaryWorker(RcSummary, this, scheduler); WorkerMap.TryAdd(localKey.ToString(), worker); RcSummary.EnqueueExecution(); return(rc); }
public OutsideSummaryWorker(RcSummaryBase rcSummary, OutsideRcManager rcManager, OutsideReactiveScheduler scheduler) { RcSummary = rcSummary; RcManager = rcManager; Scheduler = scheduler; }