use Dictionary instead of ConcurrentDictionary for safety of WebGL build, #179

master
neuecc 2020-11-09 14:34:11 +09:00
parent 854100c075
commit d5d2cb5937
1 changed files with 12 additions and 5 deletions

View File

@ -12,7 +12,9 @@ namespace Cysharp.Threading.Tasks
public static class TaskPool
{
internal static int MaxPoolSize;
static ConcurrentDictionary<Type, Func<int>> sizes = new ConcurrentDictionary<Type, Func<int>>();
// avoid to use ConcurrentDictionary for safety of WebGL build.
static Dictionary<Type, Func<int>> sizes = new Dictionary<Type, Func<int>>();
static TaskPool()
{
@ -39,19 +41,24 @@ namespace Cysharp.Threading.Tasks
}
public static IEnumerable<(Type, int)> GetCacheSizeInfo()
{
lock (sizes)
{
foreach (var item in sizes)
{
yield return (item.Key, item.Value());
}
}
}
public static void RegisterSizeGetter(Type type, Func<int> getSize)
{
lock (sizes)
{
sizes[type] = getSize;
}
}
}
public interface ITaskPoolNode<T>
{