ConcurrentPool<T> Class
Namespace: Stride.Core.ThreadingAssembly: Stride.Core.dll
A concurrent object pool.
System.Object →
ConcurrentPool<T>
Derived from ConcurrentPool<T>:
public class ConcurrentPool<T>
where T : class
Type Parameters
| Name | Description |
|---|---|
| T | The pooled item type |
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.
| Name | Description | |
|---|---|---|
| Constructors | ||
| ConcurrentPool(Func<T>) | Initializes a new instance of the ConcurrentPool<T> class. |
|
| Methods | ||
| Acquire() | Draws an item from the pool. |
|
| Release(T) | Releases an item back to the pool. |
|
Constructors
ConcurrentPool(Func<T>)
Initializes a new instance of the ConcurrentPool<T> class.
public ConcurrentPool(Func<T> factory)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Func<T> | factory | The factory method for creating new items, should the pool be empty. |
Methods
Acquire()
Draws an item from the pool.
public T Acquire()
Returns
| Type | Description |
|---|---|
| T |
Release(T)
Releases an item back to the pool.
public void Release(T item)
Parameters
| Type | Name | Description |
|---|---|---|
| T | item | The item to release to the pool. |