[gnome-sudoku] Don't crash if computer has lots of CPUs



commit 63b526d6885192dffdbf6dbdb73cccc7b0f27926
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Sat Sep 20 12:23:01 2014 -0500

    Don't crash if computer has lots of CPUs

 lib/sudoku-generator.vala |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/lib/sudoku-generator.vala b/lib/sudoku-generator.vala
index 8bbc324..462332e 100644
--- a/lib/sudoku-generator.vala
+++ b/lib/sudoku-generator.vala
@@ -28,7 +28,7 @@ public class SudokuGenerator : Object
     {
         var boards_list = new ConcurrentList<SudokuBoard> ();
         var boards = new SudokuBoard[nboards];
-        Thread<void*> threads[16];
+        var threads = new ArrayList<Thread<void*>> ();
 
         var ncpu_usable = int.max (1, (int) get_num_processors () - 1);
         var nthreads = int.min (ncpu_usable, nboards);
@@ -41,14 +41,14 @@ public class SudokuGenerator : Object
             if (i > (nthreads - remainder - 1))
                 nsudokus_per_thread = base_nsudokus_each + 1;
             var gen_thread = new GeneratorThread (nsudokus_per_thread, category, boards_list, 
generate_boards_async.callback);
-            threads[i] = new Thread<void*> ("Generator thread", gen_thread.run);
+            threads.add (new Thread<void*> ("Generator thread", gen_thread.run));
         }
 
         // Relinquish the CPU, so that the generated threads can run
         for (var i = 0; i < nthreads; i++)
         {
             yield;
-            threads[i].join ();
+            threads.get(i).join ();
         }
 
         for (var i = 0; i < boards_list.size; i++)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]