public static IEnumerable Take <T>(this ITimeBudget budget,
                                    IEnumerable <T> ts,
                                    ICollection <T> results,
                                    int steps,
                                    Predicate <T> where
                                    )
 {
     return(budget.Take(ts, results, steps, where, d => d));
 }
Exemple #2
0
        private IEnumerable ProduceNew(IConsumer <TData> consumer, List <TData> buffer, ITimeBudget budget)
        {
            int n        = Driver.BatchSize;
            var newSteps = budget.Take(Driver.EnumerateNew(), buffer, n,
                                       Driver.FilterNew, Driver.MakeData
                                       );

            foreach (var s in PostProcess(newSteps, consumer, buffer))
            {
                yield return(s);
            }
        }
Exemple #3
0
 private IEnumerable ConsumeCache(IConsumer <TData> consumer, List <TData> buffer, ITimeBudget budget)
 {
     if (_cachedResults == null)
     {
         _cachedResults = new List <TData>();
         if (_parent != null)
         {
             int n     = Driver.BatchSize;
             var steps = budget.Take(_parent._cachedResults, buffer, n, Driver.FilterCached);
             foreach (var s in PostProcess(steps, consumer, buffer))
             {
                 yield return(s);
             }
         }
     }
     else
     {
         consumer.Consume(_cachedResults);
     }
 }