template <size_t Size, size_t Alignment = alignof(std::max_align_t)>
class PmrStackArena
Defined at line 38 of file ../../src/ui/scenic/lib/utils/pmr_stack_arena.h
A stack-allocated PMR monotonic arena of `Size` bytes aligned to `Alignment`.
Because Fuchsia builds with `-ftrivial-auto-var-init=pattern`, a raw stack `std::array` or byte
array used to back a `std::pmr::monotonic_buffer_resource` would be `memset(0xAA)`-filled on
every function entry. `PmrStackArena` is annotated with `__declspec(no_init_all)` (enabled by
`-fdeclspec` in `//src/ui/scenic/lib/utils:pmr_stack_arena_config`), which instructs Clang to
skip automatic pattern-initialization for local variables of this class while still running the
constructor to initialize `resource_`.
`PmrStackArena` must be declared directly as a local stack variable (not on the heap, and not as
a member of an unannotated struct or class, because Clang checks `__declspec(no_init_all)` only
on the declared variable's type). `upstream` must be non-null and outlive the arena, and the
arena must be declared before (and outlive) all containers using `resource()`. `resource()` is
not thread-safe.
The raw backing storage `buffer_` is kept private so callers can only access it by allocating and
constructing objects through the `std::pmr::monotonic_buffer_resource`.
Public Methods
void PmrStackArena<Size, Alignment> (std::pmr::memory_resource * upstream)
Defined at line 50 of file ../../src/ui/scenic/lib/utils/pmr_stack_arena.h
void PmrStackArena<Size, Alignment> (const PmrStackArena<Size, Alignment> & )
Defined at line 55 of file ../../src/ui/scenic/lib/utils/pmr_stack_arena.h
PmrStackArena<Size, Alignment> & operator= (const PmrStackArena<Size, Alignment> & )
Defined at line 56 of file ../../src/ui/scenic/lib/utils/pmr_stack_arena.h
void PmrStackArena<Size, Alignment> (PmrStackArena<Size, Alignment> && )
Defined at line 57 of file ../../src/ui/scenic/lib/utils/pmr_stack_arena.h
PmrStackArena<Size, Alignment> & operator= (PmrStackArena<Size, Alignment> && )
Defined at line 58 of file ../../src/ui/scenic/lib/utils/pmr_stack_arena.h
std::pmr::monotonic_buffer_resource * resource ()
Defined at line 60 of file ../../src/ui/scenic/lib/utils/pmr_stack_arena.h
std::pmr::monotonic_buffer_resource * resource ()
Defined at line 63 of file ../../src/ui/scenic/lib/utils/pmr_stack_arena.h