public static void AutoParallelFor(Int64 fromInclusice, Int64 toExclusive, AutoParallelOptions options, Action <Int64, ParallelLoopState> action, ParallelMode parallelMode) { Boolean doParallel = false; if ((toExclusive - fromInclusice) > options.Threshold) { doParallel = true; } if (parallelMode == ParallelMode.ForceParallel) { doParallel = true; } else if (parallelMode == ParallelMode.NonParallel) { doParallel = false; } if (doParallel) { Parallel.For(fromInclusice, toExclusive, options, action); } else { for (Int64 i = fromInclusice; i < toExclusive; i++) { action(i, null); } } }
public static void AutoParallelForEach <T>(this IEnumerable <T> source, AutoParallelOptions options, Action <T, ParallelLoopState, Int64> action, ParallelMode parallelMode) { Boolean doParallel = false; if (source.Count() > options.Threshold) { doParallel = true; } if (parallelMode == ParallelMode.ForceParallel) { doParallel = true; } else if (parallelMode == ParallelMode.NonParallel) { doParallel = false; } if (doParallel) { Parallel.ForEach(source, options, action); } else { Int64 index = 0; foreach (var s in source) { action(s, null, index); index++; } } }
public static void AutoParallelFor <T>(IEnumerable <T> source, Int64 fromInclusice, Int64 toExclusive, AutoParallelOptions options, Action <Int64, ParallelLoopState> action) { AutoParallelFor(source, fromInclusice, toExclusive, options, action, ParallelMode.Auto); }
public static void AutoParallelFor(Int64 fromInclusice, Int64 toExclusive, AutoParallelOptions options, Action <Int64, ParallelLoopState> action) { AutoParallelFor(fromInclusice, toExclusive, options, action, ParallelMode.Auto); }
public static void AutoParallelFor <T>(IEnumerable <T> source, int fromInclusice, int toExclusive, AutoParallelOptions options, Action <int, ParallelLoopState> action, ParallelMode parallelMode) { Boolean doParallel = false; if (source.Count() > options.Threshold) { doParallel = true; } if (parallelMode == ParallelMode.ForceParallel) { doParallel = true; } else if (parallelMode == ParallelMode.NonParallel) { doParallel = false; } if (doParallel) { Parallel.For(fromInclusice, toExclusive, options, action); } else { for (int i = fromInclusice; i < toExclusive; i++) { action(i, null); } } }
public static void AutoParallelFor(int fromInclusice, int toExclusive, AutoParallelOptions options, Action <int, ParallelLoopState> action) { AutoParallelFor(fromInclusice, toExclusive, options, action, ParallelMode.Auto); }
public static void AutoParallelForEach <T>(this IEnumerable <T> source, AutoParallelOptions options, Action <T, ParallelLoopState, Int64> action) { AutoParallelForEach(source, options, action, ParallelMode.Auto); }