|
| | CreatorRecordPool (std::size_t maxLiveRecords) |
|
| CreatorRecordPool (const CreatorRecordPool &)=delete |
|
| CreatorRecordPool (CreatorRecordPool &&)=delete |
|
CreatorRecordPool & | operator= (const CreatorRecordPool &)=delete |
|
CreatorRecordPool & | operator= (CreatorRecordPool &&)=delete |
|
| ~CreatorRecordPool () |
| | Creator only, after every other thread has returned its records. Fails a release assertion if any record is still live.
|
| TaskRecord * | tryAllocate () |
| | Allocates a record.
|
|
void | releaseFromCreator (TaskRecord *record) |
| | Returns a record the creator ran itself. Creator only.
|
| void | returnFromOtherThread (TaskRecord *record) |
| | Returns a record that this thread ran.
|
| std::size_t | reclaimReturned () |
| | Moves every returned record to the free list.
|
|
std::size_t | liveCount () const |
| | Records allocated and not yet taken back. Creator only.
|
|
std::size_t | createdCount () const |
| | Records created so far; never above maxLiveRecords. Creator only.
|
|
std::size_t | maxLiveRecords () const |
| | The bound on live records.
|
template<typename Hooks = NoRecordPoolHooks>
class donner::tasks::CreatorRecordPool< Hooks >
The task records of one creator, a worker or an adoptable slot: at most maxTasksPerCreator live records, allocated by the creator alone.
The creator allocates, and returns the records it ran itself, with no atomic operation. A record that another thread ran is returned by that thread onto the pool's return stack, a lock-free multi-producer stack with one consumer: each return links the record to the head it read and publishes it with a release compare-and-swap, and the creator takes the whole stack with one acquire exchange when its free list runs empty. Since nothing pops single entries, a head that is taken, reused and returned again cannot corrupt a return that read it earlier: the compare-and-swap succeeds only if that record is the head again, and the record then links to it, which is correct.
A record is counted live from allocation until the creator takes it back, so a returned record still counts until the creator's next take. When the free list and the return stack are empty and the bound is reached, tryAllocate returns null and the caller runs the task inline.
- Template Parameters
-