From: WoochanLee Date: Sat, 8 Oct 2022 08:16:33 +0000 (+0900) Subject: [NUI] Palette use ConcurrentDictionary for thread-safe X-Git-Tag: accepted/tizen/unified/20231205.024657~653 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2951f8f38124099aac32f69fccaf5e5eae75a3de;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [NUI] Palette use ConcurrentDictionary for thread-safe --- diff --git a/src/Tizen.NUI/src/internal/Utility/ColorCutQuantizer.cs b/src/Tizen.NUI/src/internal/Utility/ColorCutQuantizer.cs index c183436..0a0fc31 100755 --- a/src/Tizen.NUI/src/internal/Utility/ColorCutQuantizer.cs +++ b/src/Tizen.NUI/src/internal/Utility/ColorCutQuantizer.cs @@ -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 colorPopulations; + private static ConcurrentDictionary colorPopulations; private static int[] colors; private List 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(); + colorPopulations = new ConcurrentDictionary(); 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