One spawned task: its closure, and what the thread that finishes it needs. More...
#include "donner/base/tasks/TaskRecord.h"
Public Member Functions | |
| TaskRecord (const TaskRecord &)=delete | |
| TaskRecord (TaskRecord &&)=delete | |
| TaskRecord & | operator= (const TaskRecord &)=delete |
| TaskRecord & | operator= (TaskRecord &&)=delete |
| template<typename F> | |
| void | setClosure (F &&work) |
Stores work as the record's closure. | |
| void | run () |
| Runs the closure, then destroys it. The record must hold one. | |
| void | discard () |
| Destroys the closure without running it. The record must hold one. | |
| bool | hasClosure () const |
| Whether the record holds a closure. | |
| void | setScope (std::atomic< std::uint64_t > *scopeCounter, Parker<> *parker, const ScopeStop *stop) |
| Records what the finisher of this task touches: its scope's counter and the parker the scope recorded; and the scope's stop request, which the thread that takes the task checks first. | |
| void | setAsyncScope (AsyncTaskScope *scope) |
| Records the asynchronous scope to notify after returning this record. | |
| AsyncTaskScope * | asyncScope () const |
| std::atomic< std::uint64_t > * | scopeCounter () const |
| The scope counter set by setScope, or null. | |
| Parker * | parker () const |
| The parker set by setScope, or null. | |
| const ScopeStop * | stop () const |
| The scope's stop request set by setScope, or null. | |
| TaskRecord * | next () const |
| The intrusive link, owned by whichever list holds the record. | |
| void | setNext (TaskRecord *next) |
| Sets the intrusive link. | |
| const void * | pool () const |
| The identity of the pool that allocated the record. | |
| Public Member Functions inherited from donner::tasks::SchedulerWork | |
| SchedulerWork (Kind kind) | |
Static Public Attributes | |
| static constexpr std::size_t | kInlineBytes = 64 |
| Bytes of closure storage inside the record. | |
| static constexpr std::size_t | kInlineAlignment = alignof(std::max_align_t) |
| Alignment of the inline closure storage. | |
| template<typename F> | |
| static constexpr bool | kStoredInline |
Whether a closure of type F is stored inline rather than in a heap block. | |
Friends | |
| template<typename> | |
| class | CreatorRecordPool |
| class | RecordStore |
Additional Inherited Members | |
| Public Types inherited from donner::tasks::SchedulerWork | |
| enum class | Kind { Record , Resumption } |
| Public Attributes inherited from donner::tasks::SchedulerWork | |
| SchedulerWork * | next = nullptr |
| const Kind | kind |
One spawned task: its closure, and what the thread that finishes it needs.
Layout: an intrusive link and work kind, its allocating pool, completion and stop metadata, the closure's call function, and 64 bytes of inline closure storage. A closure that does not fit, or needs more than max_align_t alignment, is moved into a heap block that the record owns. The record is 128 bytes, two cache lines.
Records are recycled by their pool. While a record is free, everything after its intrusive link is poisoned in AddressSanitizer builds, so a thread that touches a record after returning it fails there.
|
inline |
Stores work as the record's closure.
The record must hold none.
| work | Callable with no arguments. |
|
inline |
Records what the finisher of this task touches: its scope's counter and the parker the scope recorded; and the scope's stop request, which the thread that takes the task checks first.
| scopeCounter | The scope's counter word. |
| parker | The parker to change when the counter reaches zero. |
| stop | The scope's stop request, or null for a scope without one. |
|
staticconstexpr |
Whether a closure of type F is stored inline rather than in a heap block.