StrangeIoC
0.6.0
The IoC/Binding Framework for Unity3D and C#
|
A mechanism for storing and reusing instances. More...
Public Member Functions | |
object | GetInstance () |
Gets an instance from the pool if one is available. More... | |
void | ReturnInstance (object value) |
Returns an instance to the pool. More... | |
void | Clean () |
Remove all instance references from the Pool. More... | |
Public Member Functions inherited from strange.framework.api.IManagedList | |
IManagedList | Add (object value) |
Add a value to this List. | |
IManagedList | Add (object[] list) |
Add a set of values to this List. | |
IManagedList | Remove (object value) |
Remove a value from this List. | |
IManagedList | Remove (object[] list) |
Remove a set of values from this List. | |
Properties | |
IInstanceProvider | instanceProvider [get, set] |
A class that provides instances to the pool when it needs them. More... | |
Type | poolType [get, set] |
The object Type of the first object added to the pool. More... | |
int | available [get] |
Returns the count of non-committed instances More... | |
int | size [get, set] |
Gets or sets the size of the pool. More... | |
int | instanceCount [get] |
Returns the total number of instances currently managed by this pool. More... | |
PoolOverflowBehavior | overflowBehavior [get, set] |
Gets or sets the overflow behavior of this pool. More... | |
PoolInflationType | inflationType [get, set] |
Gets or sets the type of inflation for infinite-sized pools. More... | |
Properties inherited from strange.framework.api.IManagedList | |
object | value [get] |
Retrieve the value of this List. More... | |
A mechanism for storing and reusing instances.
Unlike much of the rest of Strange, the Pool is not a Binder, per se. Rather, it holds onto instances created by other parts of your application for use and reuse. Strange applies Pools in the CommandBinder and EventDispatcher for the recycling of those instances. But you can employ Pools yourself by mapping and injecting a Pool for instances you want to reuse.
Basic instructions for injecting a Pool for use: Map IPool<SomeClass> in the InjectionBinder:
injectionBinder.Bind<IPool<MyClass>>().ToSingleton();
Then inject like so:
[Inject] public IPool<MyClass> myPool { get; set; }
A couple of caveats for working with Pools:
void strange.extensions.pool.api.IPool.Clean | ( | ) |
Remove all instance references from the Pool.
Implemented in strange.extensions.pool.impl.Pool.
object strange.extensions.pool.api.IPool.GetInstance | ( | ) |
Gets an instance from the pool if one is available.
Implemented in strange.extensions.pool.impl.Pool, strange.extensions.pool.api.IPool< T >, and strange.extensions.pool.impl.Pool< T >.
void strange.extensions.pool.api.IPool.ReturnInstance | ( | object | value) |
Returns an instance to the pool.
If the instance being released implements IPoolable, the Release() method will be called.
value | The instance to be return to the pool. |
Implemented in strange.extensions.pool.impl.Pool.
|
get |
Returns the count of non-committed instances
|
getset |
Gets or sets the type of inflation for infinite-sized pools.
By default, a pool doubles its InstanceCount.
A PoolInflationType value.
|
get |
Returns the total number of instances currently managed by this pool.
|
getset |
A class that provides instances to the pool when it needs them.
This can be the InjectionBinder, or any class you write that satisfies the IInstanceProvider interface.
|
getset |
Gets or sets the overflow behavior of this pool.
A PoolOverflowBehavior value.
|
getset |
The object Type of the first object added to the pool.
Pool objects must be of the same concrete type. This property enforces that requirement.
|
getset |
Gets or sets the size of the pool.
The pool size. '0' is a special value indicating infinite size. Infinite pools expand as necessary to accomodate requirement.