Jump to content
  • Advertisement
Sign in to follow this  

Correct terminology for pools.

This topic is 2862 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

If I have an object stored in a pool, what would be the correct terminology for the process of making a pooled object available/unavailable.

In others words the result of one process means the object is in use and can't be taken from the pool. The result of the other process makes sure the object is no longer in use and can be taken from the pool.

Apologies if this is obvious.

Share this post


Link to post
Share on other sites
Advertisement
This is one of those problems to avoid entirely. It requires complicated checks for different scenarios through which pool elements can be tracked.

Pools work quite simply - one acquires a resource and at later point returns it. The ownership semantics here are incredibly complex and simply not worth going into, it's easier to just maintain either one or two lists which contain available elements and those that have been claimed.

It is, in general and most of the specific cases, impossible to determine whether an object is in actual use.

Share this post


Link to post
Share on other sites
I understand the need to avoid it as maintenance can be tricky but my pool is just one list with a boolean value denoting if the object is in use.

It hasn't failed me yet but I'm only allowing access to an object through the following method:


public T GetNewValidObject()
{
if (numberOfInvalidObjects > 0)
{
// Reset the wrap index to oldest object when there are invalid (unused) objects
wrapIndex = objects.Length;
return objects[--numberOfInvalidObjects];
}
else if (isWrappable)
{
if (wrapIndex == 0)
{
wrapIndex = objects.Length;
}

// Overwrite the oldest object in the pool if there are no free objects
return objects[--wrapIndex];
}

return null;
}


Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!