Class Pool<T>
A pool of objects.
Inheritance
Namespace: FM.LiveSwitch
Assembly: FM.LiveSwitch.dll
Syntax
public class Pool<T> : object where T : class
Type Parameters
Name | Description |
---|---|
T |
Constructors
Pool(Function0<T>)
Initializes a new instance of the Pool<T> class with a minimum size of 0 and a maximum size of 2,147,483,647.
Declaration
public Pool(Function0<T> createObject)
Parameters
Type | Name | Description |
---|---|---|
Function0<T> | createObject | A function that creates an object. |
Pool(Function0<T>, Int32)
Initializes a new instance of the Pool<T> class with a specified minimum size and a maximum size of 2,147,483,647.
Declaration
public Pool(Function0<T> createObject, int minSize)
Parameters
Type | Name | Description |
---|---|---|
Function0<T> | createObject | A function that creates an object. |
System.Int32 | minSize | The minimum size. |
Pool(Function0<T>, Int32, Int32)
Initializes a new instance of the Pool<T> class. with a specified minimum size and a specified maximum size.
Declaration
public Pool(Function0<T> createObject, int minSize, int maxSize)
Parameters
Type | Name | Description |
---|---|---|
Function0<T> | createObject | A function that creates an object. |
System.Int32 | minSize | The minimum size. |
System.Int32 | maxSize | The maximum size. |
Properties
Available
Gets the number of available objects.
Declaration
public int Available { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
MaxSize
Gets the maximum size. Value must be >= 0. A value of 0 indicates no maximum.
Declaration
public int MaxSize { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
MinSize
Gets the minimum size. Value must be >= 0.
Declaration
public int MinSize { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Size
Gets the current size of the pool.
Declaration
public int Size { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Methods
Destroy(Action1<T>)
Removes all items from the pool and calls a callback for each one.
Declaration
public bool Destroy(Action1<T> destroyCallback)
Parameters
Type | Name | Description |
---|---|---|
Action1<T> | destroyCallback |
Returns
Type | Description |
---|---|
System.Boolean |
Get()
Gets an object.
Declaration
public T Get()
Returns
Type | Description |
---|---|
T |
Put(T)
Put an object back.
Declaration
public bool Put(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item |
Returns
Type | Description |
---|---|
System.Boolean |