tp::JobResourcePool class

Manages the job-local resources used by tp::Job objects created from it. Enables efficient allocation and reuse of these resources between consecutive jobs. Jobs created from a tp::JobResourcePool can only be enqueued to the same device queue that the pool was created for, allowing the allocator to better reuse resources. Similar jobs that are submitted periodically therefore benefit from being allocated from the same tp::JobResourcePool.

Base classes

class Ownable
A customizable base class that is used for objects returned by the API in an OwningPtr.

Public functions

auto createJob(JobFlagMask flags = {}, const char* debugName = nullptr) -> Job
Creates a new tp::Job object that can be later enqueued to the pool's associated device queue.
auto getStatistics() const -> JobResourcePoolStatistics
Returns the current statistics of this resource pool.
auto trim(const JobSemaphore& latestTrimmed = {}) -> uint64_t
Attempts to free unused resources from the pool. Returns the number of bytes freed, if any.

Function documentation

Job tp::JobResourcePool::createJob(JobFlagMask flags = {}, const char* debugName = nullptr)

Creates a new tp::Job object that can be later enqueued to the pool's associated device queue.

Parameters
flags Additional flags for creation of the job.
debugName The debug name identifier for the job.

uint64_t tp::JobResourcePool::trim(const JobSemaphore& latestTrimmed = {})

Attempts to free unused resources from the pool. Returns the number of bytes freed, if any.

Parameters
latestTrimmed If given, serves as a hint to only free the resources that have been last used during the job associated to the given semaphore. The semaphore must be from the same queue as the one associated with this pool. If the semaphore is null, all currently unused resources may be freed.