Closed davisable closed 8 years ago
Actually the implementation is more specifically a type of cyclic cache (which I'm sure you can see) rather than a dead pool.
I have been meaning to add more flexibility as different types (and name them more accordingly).
Since the usage patterns for other types of pools are more specific, Do you have any specific usage pattern suggestions to put forward?
I come from a Unity3d background and the pool systems in use there were mostly similar -- instantiating is expensive in Unity so basically in something like this [1], after 'getting'/firing the projectile and the projectile hits something, instead of destroying the projectile sprite, you'd make it no longer visible then return it to the pool with a "Recycle" method so it can be reactivated and used.
Another feature that's common in pool implementations I've seen is to auto-grow the pool (by instantiating more pool items) if you attempt a get() after all pool elements are already used.
[1] https://gist.github.com/underscorediscovery/218decd48cc54890cc22
Right ok - so that's pretty much what I had in mind for one of the other variations.
It may make sense to make these a type of "configuration" for the pool within the existing implementation, we'll have to see if that convolutes it too much.
Thanks for the feedback!
So the
luxe.structural.Pool
implementation has acreate/new
andget
method but, unless I'm missing something, there's no way to return items to the pool after they've been used.I think this is essential for a Pool implementation.