[gnome-sudoku/gnome-3-14] sudoku-generator: fix thread-safety issue



commit 4f25c5b05e56d4d58c733f37f46758ce5678ca82
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Fri Sep 19 15:07:09 2014 -0500

    sudoku-generator: fix thread-safety issue
    
    Also, doesn't make sense to use ref for a reference-type paramater.

 lib/sudoku-generator.vala |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/lib/sudoku-generator.vala b/lib/sudoku-generator.vala
index 05c0d6c..8965c1f 100644
--- a/lib/sudoku-generator.vala
+++ b/lib/sudoku-generator.vala
@@ -26,7 +26,7 @@ public class SudokuGenerator : Object
 
     public async static SudokuBoard[] generate_boards_async (int nboards, DifficultyCategory category) 
throws ThreadError
     {
-        var boards_list = new ArrayList<SudokuBoard> ();
+        var boards_list = new ConcurrentList<SudokuBoard> ();
         var boards = new SudokuBoard[nboards];
         Thread<void*> threads[16];
 
@@ -40,7 +40,7 @@ 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, ref boards_list, 
generate_boards_async.callback);
+            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);
         }
 
@@ -94,10 +94,10 @@ public class GeneratorThread : Object
 {
     private int nsudokus;
     private DifficultyCategory level;
-    private ArrayList<SudokuBoard> boards_list;
+    private Gee.List<SudokuBoard> boards_list;
     private unowned SourceFunc callback;
 
-    public GeneratorThread (int nsudokus, DifficultyCategory level, ref ArrayList<SudokuBoard> boards_list, 
SourceFunc callback)
+    public GeneratorThread (int nsudokus, DifficultyCategory level, Gee.List<SudokuBoard> boards_list, 
SourceFunc callback)
     {
         this.nsudokus = nsudokus;
         this.level = level;


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