[NUI] Palette use ConcurrentDictionary for thread-safe
authorWoochanLee <wc0917.lee@samsung.com>
Sat, 8 Oct 2022 08:16:33 +0000 (17:16 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Wed, 12 Oct 2022 09:45:12 +0000 (18:45 +0900)
src/Tizen.NUI/src/internal/Utility/ColorCutQuantizer.cs

index c183436..0a0fc31 100755 (executable)
@@ -24,6 +24,7 @@
 using System;
 using System.Collections;
 using System.Collections.Generic;
+using System.Collections.Concurrent;
 using System.Linq;
 
 namespace Tizen.NUI
@@ -36,7 +37,7 @@ namespace Tizen.NUI
         private const int componentGreen = -2;
         private const int componentBlue = -1;
 
-        private static Dictionary<int, int> colorPopulations;
+        private static ConcurrentDictionary<int, int> colorPopulations;
         private static int[] colors;
         private List<Palette.Swatch> quantizedColors;
         private float[] tempHsl = new float[3];
@@ -59,11 +60,11 @@ namespace Tizen.NUI
 
             // First, lets pack the populations into a SparseIntArray so that they can be easily
             // retrieved without knowing a color's index
-            colorPopulations = new Dictionary<int, int>();
+            colorPopulations = new ConcurrentDictionary<int, int>();
 
             for (int i = 0; i < rawColors.Length; i++)
             {
-                colorPopulations.Add(rawColors[i], rawColorCounts[i]);
+                colorPopulations.TryAdd(rawColors[i], rawColorCounts[i]);
             }
 
             // Now go through all of the colors and keep those which we do not want to ignore