Browse Source

Correction de l'accès concurrent

bastien.monsarrat 6 years ago
parent
commit
4adfaa2c91
2 changed files with 4 additions and 2 deletions
  1. 2 1
      D15.1/Program.cs
  2. 2 1
      D15.2/Program.cs

+ 2 - 1
D15.1/Program.cs

@@ -247,6 +247,7 @@ namespace D15._1
             }
         }
 
+        private static readonly object rangeLock = new object();
         private static void GetActionList(Dictionary<(int x, int y), List<(int x, int y)>> inRangeActions, (int x, int y) root, Dictionary<(int x, int y), (int x, int y)> meta, (int x, int y) node)
         {
             var actionList = new List<(int x, int y)>();
@@ -260,7 +261,7 @@ namespace D15._1
 
             actionList.Reverse();
 
-            lock (inRangeActions) inRangeActions.Add(root, actionList);
+            lock (rangeLock) inRangeActions.Add(root, actionList);
         }
 
         private static bool GetTilesInRange(Map map, Map inRange, Unit unit, List<Unit> filtered)

+ 2 - 1
D15.2/Program.cs

@@ -260,6 +260,7 @@ namespace D15._2
             }
         }
 
+        private static readonly object rangeLock = new object();
         private static void GetActionList(Dictionary<(int x, int y), List<(int x, int y)>> inRangeActions, (int x, int y) root, Dictionary<(int x, int y), (int x, int y)> meta, (int x, int y) node)
         {
             var actionList = new List<(int x, int y)>();
@@ -273,7 +274,7 @@ namespace D15._2
 
             actionList.Reverse();
 
-            lock (inRangeActions) inRangeActions.Add(root, actionList);
+            lock (rangeLock) inRangeActions.Add(root, actionList);
         }
 
         private static bool GetTilesInRange(Map map, Map inRange, Unit unit, List<Unit> filtered)