Пример #1
0
 private async Task HandleDependencyUpdates <T>(string fullMethodKey, RcSummaryBase rcSummary, RcEnumeratorAsync <T> enumAsync)
 {
     while (rcSummary.HasDependencyOn(fullMethodKey))
     {
         try
         {
             var result = await enumAsync.NextResultAsync();
         }
         catch (ComputationStopped)
         {
             // TODO: Re-initiate summary!
             return;
         }
         catch (TimeoutException)
         {
             break;
         }
         catch (Exception e)
         {
             // Re-execute the summary that depends on this value.
             // The exception will be thrown when the summary is re-executed
             // and this sub-summary is accessed.
         }
         rcSummary.EnqueueExecution();
     }
 }
Пример #2
0
        public void EnqueueSummary(RcSummaryBase summary)
        {
            bool Bool;

            RuntimeClient.Current.ExecAction(() =>
            {
                lock (this)
                {
                    if (!queuedwork.TryGetValue(summary, out Bool))
                    {
                        queuedwork.Add(summary, true);
                        Notify();
                    }
                }
            }, Context);
        }
Пример #3
0
 public OutsideSummaryWorker(RcSummaryBase rcSummary, OutsideRcManager rcManager, OutsideReactiveScheduler scheduler)
 {
     RcSummary = rcSummary;
     RcManager = rcManager;
     Scheduler = scheduler;
 }
Пример #4
0
        protected override async Task Work()
        {
            var logger            = RcManager.Logger;
            var notificationtasks = new List <Task>();

            if (Current != null)
            {
                throw new Runtime.OrleansException("illegal state");
            }

            Dictionary <RcSummaryBase, bool> work;

            logger.Verbose("Worker {0} started", GrainId);

            lock (this)
            {
                // take all work out of the queue for processing
                work       = queuedwork;
                queuedwork = new Dictionary <RcSummaryBase, bool>();
            }


            foreach (var workitem in work)
            {
                var summary = workitem.Key;

                logger.Verbose("Worker {0} is scheduling summary {1}", GrainId, summary);

                //var context = RuntimeContext.CurrentActivationContext.CreateReactiveContext();

                object    result           = null;
                Exception exception_result = null;


                logger.Verbose("Worker {0} starts executing summary {1}", GrainId, summary);

                Current = summary;

                // Execute the computation
                try
                {
                    Current.ResetDependencies();
                    result = await Current.Execute();
                }
                catch (Exception e)
                {
                    exception_result = e;
                }
                logger.Verbose("Worker {0} starts removing dependencies", GrainId);
                Current.CleanupInvalidDependencies();
                Current = null;

                logger.Verbose("Worker {0} finished executing summary {1}, result={2}, exc={3}", GrainId, summary, result, exception_result);

                // Set the result/exception in the summary and notify dependents
                notificationtasks.Add(summary.UpdateResult(result, exception_result));
            }

            logger.Verbose("Worker {0} waiting for {1} notification tasks", GrainId, notificationtasks.Count);

            // TODO: we could batch notifications to same silo here
            await Task.WhenAll(notificationtasks);

            logger.Verbose("Worker {0} done", GrainId);
        }