private void HandleDelayedComputation(Computation computation, ITransformationContext context, OutputDelay delay) { var inCollection = Selector(computation); if (inCollection != null) { if (Persistor != null) { Type listType = (typeof(List <>)).MakeGenericType(DependencyTransformation.OutputType); IList list = System.Activator.CreateInstance(listType) as IList; MultipleResultAwaitingPersistor delayPersistor = new MultipleResultAwaitingPersistor() { List = list, Persistor = Persistor }; if (context.IsThreadSafe) { Parallel.ForEach(inCollection, dependencyInput => { HandleDelayedDependencyInput(computation, context, list, delayPersistor, dependencyInput); }); } else { foreach (var dependencyInput in inCollection) { HandleDelayedDependencyInput(computation, context, list, delayPersistor, dependencyInput); } } delay.Persistors.Add(delayPersistor); } else { if (context.IsThreadSafe) { Parallel.ForEach(inCollection, dependencyInput => { GeneralTransformationRule dependent = DependencyTransformation; var comp2 = context.CallTransformation(dependent, dependencyInput); computation.MarkRequireInternal(comp2, ExecuteBefore, this); }); } else { foreach (var dependencyInput in inCollection) { GeneralTransformationRule dependent = DependencyTransformation; var comp2 = context.CallTransformation(dependent, dependencyInput); computation.MarkRequireInternal(comp2, ExecuteBefore, this); } } } } }
private void HandleNonDelayedComputation(Computation computation, ITransformationContext context) { var output = computation.Output; var inCollection = Selector(computation); if (inCollection != null) { if (Persistor != null) { Type listType = (typeof(List <>)).MakeGenericType(DependencyTransformation.OutputType); IList list = System.Activator.CreateInstance(listType) as IList; MultipleResultAwaitingPersistor delayPersistor = new MultipleResultAwaitingPersistor() { List = list, Persistor = Persistor, Target = output }; bool needDependencyPersistor = false; GeneralTransformationRule dependent = DependencyTransformation; if (context.IsThreadSafe) { Parallel.ForEach(inCollection, dependencyInput => { if (HandleNonDelayedPersistedDependencyInput(computation, context, list, delayPersistor, dependent, dependencyInput)) { needDependencyPersistor = true; } }); } else { foreach (var dependencyInput in inCollection) { if (HandleNonDelayedPersistedDependencyInput(computation, context, list, delayPersistor, dependent, dependencyInput)) { needDependencyPersistor = true; } } } if (!needDependencyPersistor) { Persistor(output, list); } } else { GeneralTransformationRule dependent = DependencyTransformation; if (context.IsThreadSafe) { Parallel.ForEach(inCollection, dependencyInput => { var comp2 = context.CallTransformation(dependent, dependencyInput); computation.MarkRequireInternal(comp2, ExecuteBefore, this); }); } else { foreach (var dependencyInput in inCollection) { var comp2 = context.CallTransformation(dependent, dependencyInput); computation.MarkRequireInternal(comp2, ExecuteBefore, this); } } } } }
private void HandleDelayedDependencyInput(Computation computation, ITransformationContext context, IList list, MultipleResultAwaitingPersistor delayPersistor, object[] dependencyInput) { GeneralTransformationRule dependent = DependencyTransformation; var comp2 = context.CallTransformation(dependent, dependencyInput); if (!comp2.IsDelayed) { if (comp2.Output != null) { if (context.IsThreadSafe) { lock (list) { list.Add(comp2.Output); } } else { list.Add(comp2.Output); } } } else { computation.DelayOutputAtLeast(comp2.Context.MinOutputDelayLevel); delayPersistor.WaitFor(comp2); } if (ExecuteBefore) { computation.DelayTransformationAtLeast(comp2.Context.MinTransformDelayLevel); } else { comp2.DelayTransformationAtLeast(computation.Context.MinTransformDelayLevel); } }
private bool HandleNonDelayedPersistedDependencyInput(Computation computation, ITransformationContext context, IList list, MultipleResultAwaitingPersistor delayPersistor, GeneralTransformationRule dependent, object[] dependencyInput) { var needDelayedPersistor = false; var comp2 = context.CallTransformation(dependent, dependencyInput); if (!comp2.IsDelayed) { if (comp2.Output != null) { var lockList = context.IsThreadSafe; if (lockList) { lock (list) { list.Add(comp2.Output); } } else { list.Add(comp2.Output); } } } else { needDelayedPersistor = true; delayPersistor.WaitFor(comp2); } computation.MarkRequireInternal(comp2, ExecuteBefore, this); return(needDelayedPersistor); }
private void HandleNonDelayedComputation(Computation computation, ITransformationContext context) { var output = computation.Output; var inCollection = Selector(computation); if (inCollection != null) { if (Persistor != null) { Type listType = (typeof(List<>)).MakeGenericType(DependencyTransformation.OutputType); IList list = System.Activator.CreateInstance(listType) as IList; MultipleResultAwaitingPersistor delayPersistor = new MultipleResultAwaitingPersistor() { List = list, Persistor = Persistor, Target = output }; bool needDependencyPersistor = false; GeneralTransformationRule dependent = DependencyTransformation; if (context.IsThreadSafe) { Parallel.ForEach(inCollection, dependencyInput => { if (HandleNonDelayedPersistedDependencyInput(computation, context, list, delayPersistor, dependent, dependencyInput)) { needDependencyPersistor = true; } }); } else { foreach (var dependencyInput in inCollection) { if (HandleNonDelayedPersistedDependencyInput(computation, context, list, delayPersistor, dependent, dependencyInput)) { needDependencyPersistor = true; } } } if (!needDependencyPersistor) Persistor(output, list); } else { GeneralTransformationRule dependent = DependencyTransformation; if (context.IsThreadSafe) { Parallel.ForEach(inCollection, dependencyInput => { var comp2 = context.CallTransformation(dependent, dependencyInput); computation.MarkRequireInternal(comp2, ExecuteBefore, this); }); } else { foreach (var dependencyInput in inCollection) { var comp2 = context.CallTransformation(dependent, dependencyInput); computation.MarkRequireInternal(comp2, ExecuteBefore, this); } } } } }
private void HandleDelayedComputation(Computation computation, ITransformationContext context, OutputDelay delay) { var inCollection = Selector(computation); if (inCollection != null) { if (Persistor != null) { Type listType = (typeof(List<>)).MakeGenericType(DependencyTransformation.OutputType); IList list = System.Activator.CreateInstance(listType) as IList; MultipleResultAwaitingPersistor delayPersistor = new MultipleResultAwaitingPersistor() { List = list, Persistor = Persistor }; if (context.IsThreadSafe) { Parallel.ForEach(inCollection, dependencyInput => { HandleDelayedDependencyInput(computation, context, list, delayPersistor, dependencyInput); }); } else { foreach (var dependencyInput in inCollection) { HandleDelayedDependencyInput(computation, context, list, delayPersistor, dependencyInput); } } delay.Persistors.Add(delayPersistor); } else { if (context.IsThreadSafe) { Parallel.ForEach(inCollection, dependencyInput => { GeneralTransformationRule dependent = DependencyTransformation; var comp2 = context.CallTransformation(dependent, dependencyInput); computation.MarkRequireInternal(comp2, ExecuteBefore, this); }); } else { foreach (var dependencyInput in inCollection) { GeneralTransformationRule dependent = DependencyTransformation; var comp2 = context.CallTransformation(dependent, dependencyInput); computation.MarkRequireInternal(comp2, ExecuteBefore, this); } } } } }
private bool HandleNonDelayedPersistedDependencyInput(Computation computation, ITransformationContext context, IList list, MultipleResultAwaitingPersistor delayPersistor, GeneralTransformationRule dependent, object[] dependencyInput) { var needDelayedPersistor = false; var comp2 = context.CallTransformation(dependent, dependencyInput); if (!comp2.IsDelayed) { if (comp2.Output != null) { var lockList = context.IsThreadSafe; if (lockList) { lock (list) { list.Add(comp2.Output); } } else { list.Add(comp2.Output); } } } else { needDelayedPersistor = true; delayPersistor.WaitFor(comp2); } computation.MarkRequireInternal(comp2, ExecuteBefore, this); return needDelayedPersistor; }