Donner SVG main
0.8.0 ยท 766e862a0.8.0 main
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
donner::tasks::ExternalRecordPool Class Reference

The task records of every thread that is neither a worker nor an adopted thread: at most maxExternalTasks live records, shared by all of them and used only while the caller holds the guard mutex, the global queue's. More...

#include "donner/base/tasks/TaskRecord.h"

Public Member Functions

 ExternalRecordPool (std::mutex &guard, std::size_t maxLiveRecords)
 ExternalRecordPool (const ExternalRecordPool &)=delete
ExternalRecordPool & operator= (const ExternalRecordPool &)=delete
 ~ExternalRecordPool ()=default
 Fails a release assertion if any record is still live.
TaskRecord * tryAllocate (const std::unique_lock< std::mutex > &held)
 Allocates a record.
void release (TaskRecord *record, const std::unique_lock< std::mutex > &held)
 Returns a record.
std::size_t liveCount (const std::unique_lock< std::mutex > &held) const
 Records allocated and not yet returned.
std::size_t maxLiveRecords () const
 The bound on live records.

Detailed Description

The task records of every thread that is neither a worker nor an adopted thread: at most maxExternalTasks live records, shared by all of them and used only while the caller holds the guard mutex, the global queue's.

Each call takes the caller's lock as proof and fails a release assertion if it does not hold the guard.

Constructor & Destructor Documentation

◆ ExternalRecordPool()

donner::tasks::ExternalRecordPool::ExternalRecordPool ( std::mutex & guard,
std::size_t maxLiveRecords )
inline
Parameters
guardThe mutex every call must hold.
maxLiveRecordsThe bound on live records, above zero.

Member Function Documentation

◆ liveCount()

std::size_t donner::tasks::ExternalRecordPool::liveCount ( const std::unique_lock< std::mutex > & held) const
inlinenodiscard

Records allocated and not yet returned.

Parameters
heldA lock holding the guard mutex.

◆ release()

void donner::tasks::ExternalRecordPool::release ( TaskRecord * record,
const std::unique_lock< std::mutex > & held )
inline

Returns a record.

Parameters
recordA record of this pool holding no closure.
heldA lock holding the guard mutex.

◆ tryAllocate()

TaskRecord * donner::tasks::ExternalRecordPool::tryAllocate ( const std::unique_lock< std::mutex > & held)
inlinenodiscard

Allocates a record.

Parameters
heldA lock holding the guard mutex.
Returns
The record, or null when the bound is reached, in which case the caller runs the task inline.

The documentation for this class was generated from the following file: