You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Currently the pooled collections are all hard-coded to use ArrayPool<T>.Shared, but ArrayPool<T> is an abstract class intended to allow for custom implementations. For example, on a resource-constrained device someone might need an ArrayPool of a fixed size, or that pre-allocates arrays or something. At the moment there is no way to get PooledCollections to make use of such a custom ArrayPool.
Describe the solution you'd like
We need a way to optionally specify a custom ArrayPool, and default to ArrayPool<T>.Shared if none is provided. However, passing in an instance of a custom ArrayPool wouldn't work for PooledDictionary or PooledSet, because those types rely on arrays of a private type inaccessible from outside.
Perhaps there's a way to use a generic type parameter to specify the type of a custom ArrayPool, and then create an instance of this type inside the collection code?
The text was updated successfully, but these errors were encountered:
new pooledlist(arraypool x)
{
pool = arraypool ?? arraypool.shared;
}
I was trying to check how Unity works with fully their own spans-pools for their ECS. But have not found that. I hope arraypool is good abstraction may be implemented on top of Unity primitives.
Yes, exactly, to implement this I'll need to add a new ArrayPool<T> optional constructor parameter. But I can only do it for List, Stack, and Queue. Dictionary and HashSet store a private internal type in an array, so it's not possible to pass in an ArrayPool of the correct type for those classes - they will have to keep using the shared pool.
My comment about possibly creating an instance of the custom pool was a bad idea - it's not much of a pool if each instance of PooledDictionary creates its own pool.
Is your feature request related to a problem? Please describe.
Currently the pooled collections are all hard-coded to use
ArrayPool<T>.Shared
, butArrayPool<T>
is an abstract class intended to allow for custom implementations. For example, on a resource-constrained device someone might need an ArrayPool of a fixed size, or that pre-allocates arrays or something. At the moment there is no way to get PooledCollections to make use of such a custom ArrayPool.Describe the solution you'd like
We need a way to optionally specify a custom ArrayPool, and default to
ArrayPool<T>.Shared
if none is provided. However, passing in an instance of a custom ArrayPool wouldn't work for PooledDictionary or PooledSet, because those types rely on arrays of a private type inaccessible from outside.Perhaps there's a way to use a generic type parameter to specify the type of a custom ArrayPool, and then create an instance of this type inside the collection code?
The text was updated successfully, but these errors were encountered: