Skip to content

Comments

Added getters for the free objects in the pooled engine.#315

Open
GadWissberg wants to merge 1 commit intolibgdx:masterfrom
GadWissberg:pooled_engine_free_getter
Open

Added getters for the free objects in the pooled engine.#315
GadWissberg wants to merge 1 commit intolibgdx:masterfrom
GadWissberg:pooled_engine_free_getter

Conversation

@GadWissberg
Copy link

Hello,
I want in my game to monitor the number of free objects in the pools - this is to make sure I don't have cases where calling "free()" is missed and thus leading to creating limitlessly new objects. I also wanted to monitor on the components and entities, but found out there's no access to the pools themseleves. So I added 2 getters.

Thanks in advance!

* @return Number of free objects in the given component type pool.
*/
public <T extends Component> int getComponentPoolFree(Class<T> componentType) {
return componentPools.pools.get(componentType).getFree();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can throw a NullPointer should the componentType not be present in the pools.

@carlislefox
Copy link
Contributor

Hi Gad, no major concerns in principle however I would like to see the addition of a couple of tests that exercise the getComponentPoolFree() call to pick up cases such as requesting the number of objects in a pool that doesn't exist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants