Class ValueTaskSourceObjectPool<T>
- Namespace
- CryptoHives.Foundation.Threading.Pools
- Assembly
- CryptoHives.Foundation.Threading.dll
A DefaultObjectPool<T> for pooling PooledManualResetValueTaskSource<T> instances. It sets the owner pool when an instance is retrieved from the pool, so it gets automatically returned.
public class ValueTaskSourceObjectPool<T> : DefaultObjectPool<PooledManualResetValueTaskSource<T>>, IGetPooledManualResetValueTaskSource<T>
Type Parameters
T
- Inheritance
-
ValueTaskSourceObjectPool<T>
- Implements
- Inherited Members
Constructors
ValueTaskSourceObjectPool(IPooledObjectPolicy<PooledManualResetValueTaskSource<T>>, int)
Initializes a new instance of the ValueTaskSourceObjectPool<T> class.
public ValueTaskSourceObjectPool(IPooledObjectPolicy<PooledManualResetValueTaskSource<T>> policy, int maximumRetained)
Parameters
policyIPooledObjectPolicy<PooledManualResetValueTaskSource<T>>The policy to use when creating and returning objects to the pool.
maximumRetainedintThe maximum number of objects to retain in the pool.
Methods
Get()
Gets an object from the pool if one is available, otherwise creates one.
[Obsolete("Use GetPooledWaiter instead.", true)]
public override PooledManualResetValueTaskSource<T> Get()
Returns
- PooledManualResetValueTaskSource<T>
A CryptoHives.Foundation.Threading.Pools.PooledManualResetValueTaskSource{`0}.
Remarks
In this implementation, this method is not supported. Use GetPooledWaiter(object) instead.
GetPooledWaiter(object)
Retrieves a pooled instance of a manual reset value task source associated with the specified owner.
public PooledManualResetValueTaskSource<T> GetPooledWaiter(object owner)
Parameters
ownerobjectThe object that will be associated with the returned pooled waiter. Cannot be null.
Returns
- PooledManualResetValueTaskSource<T>
A pooled manual reset value task source of type T that is associated with the specified owner.
Remarks
In addition to the base Get() behavior, this method sets the owner pool and the owner of the retrieved instance. The returned instance is obtained from a pool and may be reused. The value is implicitly returned to the owner pool when the operation is complete and the result has been retrieved. The owner is needed for efficient implementation of cancellation token registration callbacks. The CancellationToken property of the returned instance is not initialized. The CancellationTokenRegistration property of the returned instance is initially set to default. The UseContinuationAsynchronously property of the returned instance is unspecified.