Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
pulp::runtime::ScopedNoAlloc Class Reference

RAII guard that marks the current thread as "must not allocate". More...

#include <scoped_no_alloc.hpp>

Public Member Functions

 ScopedNoAlloc () noexcept
 ~ScopedNoAlloc () noexcept
 ScopedNoAlloc (const ScopedNoAlloc &)=delete
ScopedNoAlloc & operator= (const ScopedNoAlloc &)=delete
 ScopedNoAlloc (ScopedNoAlloc &&)=delete
ScopedNoAlloc & operator= (ScopedNoAlloc &&)=delete

Detailed Description

RAII guard that marks the current thread as "must not allocate".

Construct a ScopedNoAlloc at the entry of a real-time-safe region (audio callback, paint cycle) and let it destruct on the way out. While any instance is alive on the calling thread, is_in_no_alloc_scope() returns true.

On its own this class only tracks state — it does not intercept operator new. The intent is that:

  • Pulp's audio (Processor::process) and paint (View::paint_all) paths are wrapped in ScopedNoAlloc, so the contract is enforced uniformly.
  • Sanitizers / debug allocator hooks can query is_in_no_alloc_scope() and abort / log if an allocation sneaks into the scope. This class is the contract surface.
  • The guard is a no-op in NDEBUG so it costs nothing in release builds — same shape as PULP_DBG_ASSERT.

Follows the same approach as dedicated RT-safety libraries like radsan, built on the principle that UI paint should be treated as carefully as the audio thread.

Constructor & Destructor Documentation

◆ ScopedNoAlloc() [1/3]

pulp::runtime::ScopedNoAlloc::ScopedNoAlloc ( )
noexcept

◆ ~ScopedNoAlloc()

pulp::runtime::ScopedNoAlloc::~ScopedNoAlloc ( )
noexcept

◆ ScopedNoAlloc() [2/3]

pulp::runtime::ScopedNoAlloc::ScopedNoAlloc ( const ScopedNoAlloc & )
delete

◆ ScopedNoAlloc() [3/3]

pulp::runtime::ScopedNoAlloc::ScopedNoAlloc ( ScopedNoAlloc && )
delete

Member Function Documentation

◆ operator=() [1/2]

ScopedNoAlloc & pulp::runtime::ScopedNoAlloc::operator= ( const ScopedNoAlloc & )
delete

◆ operator=() [2/2]

ScopedNoAlloc & pulp::runtime::ScopedNoAlloc::operator= ( ScopedNoAlloc && )
delete

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