Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
runtime.hpp
Go to the documentation of this file.
1#pragma once
2
3// Convenience header — includes all runtime utilities
4//
5// ── Thread synchronization strategy ─────────────────────────────────────
6//
7// Pulp uses different primitives depending on the data flow pattern:
8//
9// | Pattern | Primitive | Example |
10// |----------------------------|------------------|------------------------------|
11// | Single value, latest-wins | std::atomic<T> | Parameter values, flags |
12// | Multi-field coherent read | SeqLock<T> | Transport state (tempo+beat) |
13// | Large data swap | TripleBuffer<T> | Wavetables, IR buffers |
14// | Ordered event stream | SPSC FIFO | MIDI events, UI commands |
15// | Occurrence signals/counts | ActivityChannel | Pad flashes, UI triggers |
16// | Latest-value metering | TripleBuffer<T> | Audio→UI meter data |
17// | Prepared read-only pointer | RealtimeResourceSlot<T,N> | prepared samples/IRs |
18//
19// RealtimeResourceSlot is a raw-pointer publication helper, not reader-pinned
20// RCU: one non-RT owner serializes publish/reclaim and reclaims only after a
21// block-boundary grace point. Use the Slot/Handoff taxonomy where a site needs
22// multi-reader pins or audio-thread ownership transfer.
23//
24// NEVER use on the audio thread:
25// std::mutex, std::condition_variable, heap allocation, I/O
26//
27// Memory ordering:
28// - ParamValue uses relaxed atomics (independent single values, no ordering
29// dependency between parameters)
30// - SeqLock uses acquire/release (ensures coherent multi-field snapshots)
31// - TripleBuffer uses acquire/release on the flag word
32// - EventLoop uses acquire/release + condition_variable (UI thread only)
33// - RealtimeResourceSlot publishes a prepared pointer with release/acquire;
34// reclaim retired resources away from the audio thread after a grace point
35
41#include <pulp/runtime/log.hpp>
Lock-free occurrence signals between realtime and control/UI threads.
FixedFunction<Signature, Capacity> - a move-only callable wrapper with inline storage that never touc...
Lock-free sequence-lock for coherent multi-field snapshots.
Lock-free latest-value publication between two threads.