Add the ability to clear all pools in Pools
See original GitHub issueI think it would be useful to add the ability to clear all pools that are stored internally in Pools via the static
variable typePools
.
The implementation seems to be rather straightforward: Simply iterate over all the pools
and call their clear
method. Something like this:
public class Pools {
// ...
public static void clear() {
for (ObjectMap.Entry<Class, Pool> entry : typePools) {
entry.value.clear();
}
}
}
Issue Analytics
- State:
- Created 8 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Pool Flocculant: How Does It Work and Is It Better Than Pool ...
A fast-acting formula that drops cloudy water particles to the bottom of the pool so you can vacuum it out. Fast Floc will...
Read more >Open Your Own Pool & Keep it Clean All Season - EASY TIPS
You can spend upwards of $500 to have your pool opened! See how I open my pool for $10 & share tricks to...
Read more >How To Clear A Green Pool FAST | Swim University - YouTube
Is your pool water green? The good news is you don't have to drain your pool and start over to get rid of...
Read more >How Do I Make My Pool Water Crystal Clear? - CMP
If the filter and circulation are working correctly, adding the proper amount of chlorine can clear a pool right up. Check out our...
Read more >How to Manage Connection Pools for PostgreSQL Database ...
The Pool Name doesn't affect how your pool functions, but it must be unique and it cannot be edited once the pool is...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m going to close this, as a valid use case that doesn’t abuse the handling of
Disposables
was never demonstrated. Disposables aren’t practical to place into ReflectionPools, as any of the libGDX classes implementing Disposable are unlikely to have a useful empty constructor and also be the sort of thing you need many of.Suppose you want to pool Pixmaps or FrameBuffers. These don’t have useful empty constructors. You would need to make your own Pool that calls a specific constructor with specific parameters in
newObject()
. And then you canfreeAll()
your own pool when the game is disposed.If a reflection-pooled class references Disposable objects that it does not own, it should null out the references in
reset()
.@asherbar, I think @xGnoSiSx was maybe assuming this clearing would be automatically done, which I don’t think you were suggesting.
Seems like since this is apparently the only use case, you’d actually want a
clearDisposables
method that clears only the objects that implement Disposable. The sample code you gave would result in leaking all Disposables. It should look something like this: