RecyclableList.IndexOf parallel performance improvements.

This commit is contained in:
mlemanczyk committed 2023-05-03 12:36:37 +02:00
1 parent 99600d4854
commit 3db10d7602
21 files changed
+4282 -511

No files matched your search

@@ -0,0 +1,35 @@
using System.Buffers;
using System.Collections.Concurrent;
namespace Recyclable.Collections.Pools
{
public static class RecyclableArrayPool<T>
{
public static readonly OneSizeArrayPool<T> Null = new(0, 0);
private static readonly ConcurrentDictionary<int, ArrayPool<T>> _pools = new();
public static ArrayPool<T> Shared(int blockSize)
{
//lock (_lock)
{
if (!_pools.TryGetValue(blockSize, out ArrayPool<T>? pool))
{
pool = new OneSizeArrayPool<T>(blockSize, 100);
pool = _pools.TryAdd(blockSize, pool) ? pool : _pools[blockSize];
}
return pool;
}
//_lock.Wait();
//try
//{
//}
//finally
//{
// _lock.Release();
//}
}
}
}