[gnome-sudoku/gnome-3-14] sudoku-generator: use g_get_num_processors()
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-sudoku/gnome-3-14] sudoku-generator: use g_get_num_processors()
- Date: Sat, 4 Oct 2014 00:54:19 +0000 (UTC)
commit 9ff3929ec139c316afcdbb5cc595888a7d8029e1
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Fri Sep 19 15:11:01 2014 -0500
sudoku-generator: use g_get_num_processors()
This would have been good to have known about earlier. :(
lib/sudoku-generator.vala | 18 +-----------------
1 files changed, 1 insertions(+), 17 deletions(-)
---
diff --git a/lib/sudoku-generator.vala b/lib/sudoku-generator.vala
index 80fdcef..b6cb145 100644
--- a/lib/sudoku-generator.vala
+++ b/lib/sudoku-generator.vala
@@ -49,7 +49,7 @@ public class SudokuGenerator : Object
var boards = new SudokuBoard[nboards];
var threads = new ArrayList<Thread<void*>> ();
- var ncpu_usable = int.max (1, get_number_of_processors () - 1);
+ var ncpu_usable = int.max (1, (int) get_num_processors () - 1);
var nthreads = int.min (ncpu_usable, nboards);
var base_nsudokus_each = nboards / nthreads;
var remainder = nboards % nthreads;
@@ -91,22 +91,6 @@ public class SudokuGenerator : Object
{
return QQwing.get_version ();
}
-
- private static int get_number_of_processors ()
- {
- int ncpu;
- string nproc_stdout;
-
- try {
- Process.spawn_command_line_sync ("nproc", out nproc_stdout);
- ncpu = int.parse (nproc_stdout);
- } catch (SpawnError e) {
- warning ("Call to nproc failed. Puzzles will be generated in a single thread");
- ncpu = 1;
- }
-
- return ncpu;
- }
}
public class GeneratorThread : Object
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]