Table of Contents

Class ConcurrentPool<T>

Namespace
Stride.Core.Threading
Assembly
Stride.Core.dll

A concurrent object pool.

public class ConcurrentPool<T> where T : class

Type Parameters

T

The pooled item type

Inheritance
ConcurrentPool<T>

Remarks

Circular buffer segments are used as storage. When full, new segments are added as tail. Items are only appended to the tail segment. When the head segment is empty, it will be discarded. After stabilizing, only a single segment exists at a time, causing no further segment allocations or locking.

Constructors

ConcurrentPool(Func<T>)

Initializes a new instance of the ConcurrentPool<T> class.

public ConcurrentPool(Func<T> factory)

Parameters

factory Func<T>

The factory method for creating new items, should the pool be empty.

Methods

Acquire()

Draws an item from the pool.

public T Acquire()

Returns

T

Release(T)

Releases an item back to the pool.

public void Release(T item)

Parameters

item T

The item to release to the pool.