Class ManagedPools
A managed pooling system implementation primarily meant for the object oriented patterns, based on the C# base object.
Inheritance
Namespace: GDX.Collections.Pooling
Syntax
[VisualScriptingCompatible((short)1)]
public static class ManagedPools
Methods
| Improve this Doc View SourceGetNextPoolKey()
Get the next available pool key.
Declaration
public static uint GetNextPoolKey()
Returns
| Type | Description |
|---|---|
| System.UInt32 | A unique pool identifying key. |
Remarks
Increments the previously issued stored value, and returns the new value.
GetPool(UInt32)
Get a registered IManagedPool based on its key.
Declaration
public static IManagedPool GetPool(uint key)
Parameters
| Type | Name | Description |
|---|---|---|
| System.UInt32 | key | The unique key to use when looking for the IManagedPool. |
Returns
| Type | Description |
|---|---|
| IManagedPool | An IManagedPool identified by the provided |
GetPool<T>(UInt32)
Get a registered IManagedPool based on its key.
Declaration
public static T GetPool<T>(uint key)
Parameters
| Type | Name | Description |
|---|---|---|
| System.UInt32 | key | The unique key to use when looking for the IManagedPool. |
Returns
| Type | Description |
|---|---|
| T | A type casted pool identified by the provided |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the pool, used to cast the return pool |
GetPoolWithContainsCheck(UInt32)
Get a registered IManagedPool based on its key, first checking if it is
registered.
Declaration
public static IManagedPool GetPoolWithContainsCheck(uint key)
Parameters
| Type | Name | Description |
|---|---|---|
| System.UInt32 | key | The unique key to use when looking for the IManagedPool. |
Returns
| Type | Description |
|---|---|
| IManagedPool | An IManagedPool identified by the provided |
GetPoolWithContainsCheck<T>(UInt32)
Get a registered IManagedPool based on its key, first checking if it is
registered.
Declaration
public static T GetPoolWithContainsCheck<T>(uint key)
where T : class
Parameters
| Type | Name | Description |
|---|---|---|
| System.UInt32 | key | The unique key to use when looking for the IManagedPool. |
Returns
| Type | Description |
|---|---|
| T | A type casted pool identified by the provided |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the pool, used to cast the return pool |
HasPool(UInt32)
Is an IManagedPool registered with the provided key?
Declaration
public static bool HasPool(uint key)
Parameters
| Type | Name | Description |
|---|---|---|
| System.UInt32 | key | A unique pool key |
Returns
| Type | Description |
|---|---|
| System.Boolean | true if a pool is found registered with this system, false otherwise. |
Register(IManagedPool)
Register a IManagedPool with the global management system.
Declaration
public static void Register(IManagedPool managedPool)
Parameters
| Type | Name | Description |
|---|---|---|
| IManagedPool | managedPool | Target IManagedPool |
ReturnAll(Boolean)
Attempts to return all spawned items to their original IManagedPools.
Declaration
public static void ReturnAll(bool shouldShrink = true)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | shouldShrink | Should the pool be shrunk (destroying created items) to its original set minimum size? |
TearDown(Boolean)
Execute TearDown() (destroying contents) on all registered IManagedPool which have been flagged to accept it, evaluated by IsAllowedManagedTearDown().
Declaration
public static void TearDown(bool forceAll = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | forceAll | Execute TearDown() regardless of the IsAllowedManagedTearDown() response. |
Remarks
This will unregister the IManagedPool itself as well.
TryGetFirstPool(Object, out IManagedPool)
Attempt to get an IManagedPool based on the baseObject.
Declaration
public static bool TryGetFirstPool(object baseObject, out IManagedPool pool)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | baseObject | The System.Object which was used to create the pool. |
| IManagedPool | pool | The first found IManagedPool created with |
Returns
| Type | Description |
|---|---|
| System.Boolean | true/false if an IManagedPool was found. |
Unregister(IManagedPool)
Unregister a IManagedPool from with the management system.
Declaration
public static void Unregister(IManagedPool managedPool)
Parameters
| Type | Name | Description |
|---|---|---|
| IManagedPool | managedPool | Target IManagedPool |