|
| Pool (MemBlockType memType=MemBlockType::Bucket) |
| Create a pool with default capacity and page size.
|
|
| Pool (ElementOffset capacity, ElementOffset pageSize=128, MemBlockType memType=MemBlockType::Bucket) |
| Create a pool with the given capacity and page sizes given in number of elements.
|
|
| Pool (ElementOffset capacity, ElementOffset pageSize, Memory::Allocator *allocator, MemBlockType memType=MemBlockType::Bucket) |
| Create a pool with the given capacity and page sizes given in number of elements.
|
|
| Pool (Pool &&) noexcept=default |
| Defaulted move constructor.
|
|
Pool & | operator= (Pool &&) noexcept=default |
| Defaulted move assignment operator.
|
|
| Pool (const Pool &)=delete |
| Disallow copying Pool instances.
|
|
Pool & | operator= (const Pool &)=delete |
| Disallow copy-assigning pool instances.
|
|
void | resize (size_t capacity) |
| Resize the pool to the given capacity.
|
|
template<typename... ARGS> |
ElementType * | create (ARGS &&... args) |
| Allocate and initialize a new element from the pool passing any arguments to the constructor of the new item as necessary.
|
|
void | destroy (ElementType *element) |
| Free and destroy the given element in the pool.
|
|
size_t | size () const |
| Get the size of the pool, i.e the number of created elements.
|
|
size_t | getCapacity () const |
| Get the capacity of the pool, i.e the number of elements that may be allocated before any additional pages must be created.
|
|
size_t | getPageSize () const |
| Get the page size in number of elements.
|
|
ElementHandle | getHandle (ElementType *element) const |
| Get a handle for the given element.
|
|
ElementType * | operator[] (ElementHandle handle) |
| Lookup an element using the handle given, using constant time.
|
|
bool | isValid (ElementHandle handle) const |
| Checks if the given handle is a valid handle to an allocated or free element.
|
|
bool | isAllocated (ElementHandle handle) const |
| Checks if the given handle is a valid handle to an allocated element.
|
|
template<typename ElementType>
struct Cogs::Collections::Pool< ElementType >
Pool used to store elements of ElementType.
- Template Parameters
-
ElementType | Type of elements to store in the pool. The size requirements for storage are at least the size of a pointer. |
Definition at line 16 of file Pool.h.
template<typename ElementType >
template<typename... ARGS>
Allocate and initialize a new element from the pool passing any arguments to the constructor of the new item as necessary.
The pool will grow as needed if no free elements are available to use or reuse.
- Returns
- A pointer to the newly allocated element. The pointer remains valid after resizing the pool.
Definition at line 69 of file Pool.h.
Referenced by Cogs::Core::TaskQueue::createTask().