Class Leap::Pool¶
- class Leap.Pool<T>¶
-
A very lightweight pool implementation. When you call Spawn, an object of type T will be returned. If the pool was not empty, the T will be taken from the pool. If the pool was empty, a new T will be constructed and returned instead. Calling recycle will return a T to the pool.
It is not required to implement the IPoolable interface to use the Pool class, which allows you to pool types such as List or Dictionary, types which you have no control over. But make sure that you clean up these objects before you recycle them!
Example workflow for types you DO NOT have control over:
// " // (XML fix for Visual Studio) var obj = Pool\<T\>.Spawn(); obj.Init(stuff); //Do something with obj obj.Clear(); Pool\<T\>.Recycle(obj); // " // (Close XML fix for Visual Studio)
Example workflow for types you DO have control over:
// " // (XML fix for Visual Studio) var obj = Pool\<T\>.Spawn(); obj.Init(stuff); // Do something with obj obj.Dispose(); // e.g. call Recycle(this) in the Dispose() implementation // " // (Close XML fix for Visual Studio)
Public Static Functions
- static void Recycle (T t0, T t1)¶
Calls Recycle for each argument.
- static void Recycle (T t0, T t1, T t2)
Calls Recycle for each argument.
- static void Recycle (T t0, T t1, T t2, T t3)
Calls Recycle for each argument.