|
ecor
|
Async arena. More...
#include <ecor.hpp>
Public Member Functions | |
| async_arena (async_arena &&)=delete | |
| async_arena (async_arena const &)=delete | |
| async_arena (Ctx &ctx, Mem &mem) noexcept | |
| Construct an async arena with the provided context and memory resource. | |
| _ll_sender< set_value_t() > | async_destroy () noexcept |
Signal that no new objects will be created and return a sender that completes with set_value_t() when all pending async destructions have finished. | |
| template<typename T , typename... Args> | |
| async_ptr< T, Ctx, Mem > | make (Args &&... args) |
| Create a new managed object of type T. More... | |
| async_arena & | operator= (async_arena &&)=delete |
| async_arena & | operator= (async_arena const &)=delete |
Async arena.
Creates async_ptr instances and provides graceful shutdown via async_destroy(). This allows construction of datasets of type with asynchronous destruction requirements, and ensures that all pending destructions complete before shutdown.
For any type managed by the arena, we assume that async_destroy CPO can be used and guaranteee that it's get called before standard destructor of the object.
Arena uses reference-counted pointers to handle lifetime of the objects. When the last async_ptr to an object is destroyed, the arena initiates asynchronous destruction of the object by enqueuing it for cleanup in provided task context object. The arena keeps track of all alive objects and pending destructions, and provides a sender that completes when all pending destructions have finished after shutdown is initiated.
Any memory is allocated via Mem memory resource provided to the arena. Arena allocates newly created objects and all internal bookkeeping structures (control blocks, destroy operations) from the provided memory resource, and deallocates them when they are destroyed.
The resulting operation state from sender returned by objects async_destroy() is stored in memory blocked allocated from the arena's memory resource, and is properly destroyed and deallocated when the destruction completes.
The arena itself is not thread-safe and must be used from a single task context.
Precondition: async_destroy() sender must complete before the arena is destroyed.
|
inline |