Class Pool<T>
Holds a collection of so they can be re-used without allocations
Inheritance
System.Object
Inherited Members
Show
Syntax
public class Pool<T>
where T : class
Type Parameters
Name | Description |
---|---|
T |
Constructors
Pool(Pool<T>.CreateNewItemNoCount, Int32, Int32, ILogger)
Creates pool, that does not require Buffer size
Declaration
public Pool(Pool<T>.CreateNewItemNoCount createNew, int startPoolSize, int maxPoolSize, ILogger logger = null)
Parameters
Type | Name | Description |
---|---|---|
Mirage.SocketLayer.Pool.CreateNewItemNoCount<> | createNew | |
System.Int32 | startPoolSize | how many buffers to create at start |
System.Int32 | maxPoolSize | max number of buffers in pool |
ILogger | logger |
Pool(Pool<T>.CreateNewItem, Int32, Int32, Int32, ILogger)
Creates pool where buffer size will be passed to items when created them
Declaration
public Pool(Pool<T>.CreateNewItem createNew, int bufferSize, int startPoolSize, int maxPoolSize, ILogger logger = null)
Parameters
Type | Name | Description |
---|---|---|
Mirage.SocketLayer.Pool.CreateNewItem<> | createNew | |
System.Int32 | bufferSize | size of each buffer |
System.Int32 | startPoolSize | how many buffers to create at start |
System.Int32 | maxPoolSize | max number of buffers in pool |
ILogger | logger |
Properties
Metrics
Declaration
public PoolMetrics Metrics { get; }
Methods
Configure(Int32, Int32)
sets max pool size and then creates writers up to new start size
Declaration
public void Configure(int startPoolSize, int maxPoolSize)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | startPoolSize | |
System.Int32 | maxPoolSize |
Take()
Declaration
public T Take()
Returns
Type | Description |
---|---|
T |
Put(T)
Declaration
public void Put(T buffer)
Parameters
Type | Name | Description |
---|---|---|
T | buffer |