Ejemplo n.º 1
0
        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);
                }
            }
        }
Ejemplo n.º 2
0
        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++;
                }
            }
        }
Ejemplo n.º 3
0
 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);
 }
Ejemplo n.º 4
0
 public static void AutoParallelFor(Int64 fromInclusice, Int64 toExclusive, AutoParallelOptions options, Action <Int64, ParallelLoopState> action)
 {
     AutoParallelFor(fromInclusice, toExclusive, options, action, ParallelMode.Auto);
 }
Ejemplo n.º 5
0
        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);
                }
            }
        }
Ejemplo n.º 6
0
 public static void AutoParallelFor(int fromInclusice, int toExclusive, AutoParallelOptions options, Action <int, ParallelLoopState> action)
 {
     AutoParallelFor(fromInclusice, toExclusive, options, action, ParallelMode.Auto);
 }
Ejemplo n.º 7
0
 public static void AutoParallelForEach <T>(this IEnumerable <T> source, AutoParallelOptions options, Action <T, ParallelLoopState, Int64> action)
 {
     AutoParallelForEach(source, options, action, ParallelMode.Auto);
 }