|
ProtoCore v0.0.1
Deterministic, zero-heap network stack for embedded targets
|
A scratch borrow whose acquire and release are one call each. More...
#include <scratch.h>
Public Member Functions | |
| ScratchBorrow (size_t n, size_t align) | |
| ~ScratchBorrow () | |
| ScratchBorrow (const ScratchBorrow &)=delete | |
| ScratchBorrow & | operator= (const ScratchBorrow &)=delete |
| const pc_span & | span () const |
| The borrowed region; empty if the arena could not satisfy it. | |
A scratch borrow whose acquire and release are one call each.
ScratchScope + pc_scratch_span costs three crossings of this module's boundary: mark, alloc, then release. Mark and alloc always happen together, so one of those is structure rather than work. This does both in the constructor and the release in the destructor - two calls, and the slot is resolved once instead of twice.
The pool's state stays private to the .cpp; that is exactly why these cannot be inlined instead, and why LTO would have been the alternative (it is unavailable here - the ESP32 core does not link with -flto).
Fails closed like every other borrow: an exhausted arena leaves span() empty, so a caller that omits the check writes nothing rather than dereferencing null.
| ScratchBorrow::ScratchBorrow | ( | size_t | n, |
| size_t | align | ||
| ) |
Definition at line 118 of file scratch.cpp.
References pc_arena_scratch_alloc_aligned(), pc_arena_scratch_mark(), and pc_span_from().
| ScratchBorrow::~ScratchBorrow | ( | ) |
Definition at line 128 of file scratch.cpp.
References pc_arena_scratch_release().
|
delete |
|
delete |
|
inline |
The borrowed region; empty if the arena could not satisfy it.
Definition at line 176 of file scratch.h.
Referenced by pc_ssh_server_dispatch().