Allow using a worker number that is greater than Environment.ProcessorCount for paral...
authorJérémie Laval <jeremie.laval@gmail.com>
Wed, 27 Jul 2011 20:22:24 +0000 (16:22 -0400)
committerJérémie Laval <jeremie.laval@gmail.com>
Wed, 27 Jul 2011 20:22:24 +0000 (16:22 -0400)
mcs/class/corlib/System.Threading.Tasks/Parallel.cs

index 15f1fcc0c05dfa9328968de1633aed0b617f57f0..5e7e8b740f9cb06789043a0b9983a6102777ec29 100644 (file)
@@ -51,8 +51,9 @@ namespace System.Threading.Tasks
 
                static int GetBestWorkerNumber (int from, int to, ParallelOptions options, out int step)
                {
-                       int num = Math.Min (GetBestWorkerNumber (options.TaskScheduler),
-                                           options != null && options.MaxDegreeOfParallelism != -1 ? options.MaxDegreeOfParallelism : int.MaxValue);
+                       int num = GetBestWorkerNumber(options.TaskScheduler);
+                       if (options != null && options.MaxDegreeOfParallelism != -1)
+                               num = options.MaxDegreeOfParallelism;
                        // Integer range that each task process
                        if ((step = (to - from) / num) < 5) {
                                step = 5;