[gnome-sudoku/gnome-3-14] Don't crash if computer has lots of CPUs
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-sudoku/gnome-3-14] Don't crash if computer has lots of CPUs
- Date: Sun, 21 Sep 2014 15:16:32 +0000 (UTC)
commit 21305590c2d6f2d5477e423a652c447e11cdd82e
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 8965c1f..0f7294a 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, get_number_of_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]