ProtoCore v0.0.1
Deterministic, zero-heap network stack for embedded targets
Loading...
Searching...
No Matches
ScratchBorrow Class Reference

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
 
ScratchBorrowoperator= (const ScratchBorrow &)=delete
 
const pc_spanspan () const
 The borrowed region; empty if the arena could not satisfy it.
 

Detailed Description

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.

Definition at line 167 of file scratch.h.

Constructor & Destructor Documentation

◆ ScratchBorrow() [1/2]

ScratchBorrow::ScratchBorrow ( size_t  n,
size_t  align 
)

◆ ~ScratchBorrow()

ScratchBorrow::~ScratchBorrow ( )

Definition at line 128 of file scratch.cpp.

References pc_arena_scratch_release().

◆ ScratchBorrow() [2/2]

ScratchBorrow::ScratchBorrow ( const ScratchBorrow )
delete

Member Function Documentation

◆ operator=()

ScratchBorrow & ScratchBorrow::operator= ( const ScratchBorrow )
delete

◆ span()

const pc_span & ScratchBorrow::span ( ) const
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().


The documentation for this class was generated from the following files: