Skip to main content

Module rt

Module rt 

Source
Expand description

Paranoid real-time allocation checking (the rt-paranoid feature).

A wrapping global allocator (RtCheckAlloc) plus a thread-local “audio section” guard (RtSection). While the audio thread is inside a section, any allocation it makes is a real-time contract violation and gets recorded and reported.

The section is entered around the single plugin.process() call in chunked_process, which every format wrapper and the test driver route through, so one guard covers all of them. The allocator is installed by the artifact (a plugin cdylib via truce::plugin!, or a test binary) with truce::enable_rt_paranoid!; a library cannot set a downstream binary’s global allocator.

Everything here is inert unless the rt-paranoid feature is on: RtSection::enter is a zero-sized no-op and allow_alloc just calls the closure, so release builds are unaffected.

Structs§

Mutex
A std::sync::Mutex that, with rt-paranoid on, flags a lock taken on the audio thread inside a process section. A plugin that wants lock checking uses this in place of the std type; with the feature off it is a zero-cost newtype that just delegates.
RtSection
No-op real-time section guard. With rt-paranoid off this is a zero-sized type whose enter/drop compile away.
RwLock
A std::sync::RwLock that, with rt-paranoid on, flags a read or write taken on the audio thread inside a process section. Same coverage caveat as Mutex.

Enums§

Mode
What the checker does on a violation. Present with the feature off so set_mode call sites compile unconditionally; the checker is inert, so it has no effect.

Functions§

allow_alloc
No-op with rt-paranoid off: just calls f.
audit
No-op with rt-paranoid off: runs f, reports zero allocations.
check_dealloc
Always false with rt-paranoid off.
is_active
The checker is not compiled in.
set_check_dealloc
No-op with rt-paranoid off.
set_mode
No-op with rt-paranoid off.