mirror of https://github.com/Cysharp/UniTask
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
|
public static class TaskPool
|
||||||
{
|
{
|
||||||
internal static int MaxPoolSize;
|
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()
|
static TaskPool()
|
||||||
{
|
{
|
||||||
|
@ -40,19 +42,24 @@ namespace Cysharp.Threading.Tasks
|
||||||
|
|
||||||
public static IEnumerable<(Type, int)> GetCacheSizeInfo()
|
public static IEnumerable<(Type, int)> GetCacheSizeInfo()
|
||||||
{
|
{
|
||||||
foreach (var item in sizes)
|
lock (sizes)
|
||||||
{
|
{
|
||||||
yield return (item.Key, item.Value());
|
foreach (var item in sizes)
|
||||||
|
{
|
||||||
|
yield return (item.Key, item.Value());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void RegisterSizeGetter(Type type, Func<int> getSize)
|
public static void RegisterSizeGetter(Type type, Func<int> getSize)
|
||||||
{
|
{
|
||||||
sizes[type] = getSize;
|
lock (sizes)
|
||||||
|
{
|
||||||
|
sizes[type] = getSize;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public interface ITaskPoolNode<T>
|
public interface ITaskPoolNode<T>
|
||||||
{
|
{
|
||||||
ref T NextNode { get; }
|
ref T NextNode { get; }
|
||||||
|
|
Loading…
Reference in New Issue