use Dictionary instead of ConcurrentDictionary for safety of WebGL build, #179
parent
854100c075
commit
d5d2cb5937
|
@ -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>
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue