|
Cogs.Core
|
Task pool providing fast and easy allocation and deallocation of Task instances. More...
Public Member Functions | |
| TaskPool () | |
| Construct a task pool with a default capacity of 1024 tasks. | |
Public Member Functions inherited from Cogs::Collections::Pool< Task > | |
| 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 (const Pool &)=delete | |
| Disallow copying Pool instances. | |
| Pool & | operator= (Pool &&) noexcept=default |
| Defaulted move assignment operator. | |
| Pool & | operator= (const Pool &)=delete |
| Disallow copy-assigning pool instances. | |
| void | resize (size_t capacity) |
| Resize the pool to the given capacity. | |
| Task * | 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 (Task *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 (Task *element) const |
| Get a handle for the given element. | |
| Task * | 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. | |
Task pool providing fast and easy allocation and deallocation of Task instances.
Uses the intrusive linked list defined by Task::next to chain free Task instances together, making allocation a new task a matter of returning the first available task from the chain and updating the head pointer.
Definition at line 90 of file TaskManager.cpp.
|
inline |
Construct a task pool with a default capacity of 1024 tasks.
Definition at line 94 of file TaskManager.cpp.