class
SushiDSP::RtSwapSlot
template <typename T>Publishes replacement objects of type T to the audio thread without locking or blocking it, and frees a retired object only once the audio thread has moved past it.
- Declared in
include/SushiDSP/core/RtSwapSlot.hpp
publish() and reclaim() belong to one non-RT thread and acquire_for_audio_thread() to one audio thread; the slot synchronises neither side against itself (include/SushiDSP/README.md).
Template parameters
TThe published object type. Owned by the slot; destroyed by reclaim() or by the slot's destructor.
Public member functions
RtSwapSlot()=default~RtSwapSlot()=defaultRtSwapSlot(const RtSwapSlot &)=deleteRtSwapSlot & operator=(const RtSwapSlot &)=deletevoid publish(std::unique_ptr< T > new_object)Makes new_object the active object for subsequent acquire_for_audio_thread() calls.
Not real-time safe; call only off the audio thread. Must be called from a single, consistent non-RT thread (or externally synchronized if called from more than one) - see the class-level threading contract.
Parameters
new_objectThe fully constructed object to publish. Must not be null.
T * acquire_for_audio_thread() noexceptReturns the current active object and records that this generation is now in use.
Real-time safe: one atomic load, one atomic store, no allocation. Must be called from a single, consistent audio thread - see the class-level threading contract.
Returns
The active object, or nullptr if publish() was never called. The returned pointer is valid only until this same thread's NEXT call to acquire_for_audio_thread(); do not retain it across calls.
bool has_active() const noexceptReports whether anything has been published yet.
Real-time safe: one atomic load, no allocation. Unlike acquire_for_audio_thread() this records no generation, so it neither holds a retired object alive nor releases one.
Returns
True if an active object exists, false if publish() was never called.
T * active_for_publisher() const noexceptReturns the active object without recording a generation.
Publisher-thread only: call it from the same non-RT thread as publish() and reclaim(). That thread owns retired_, so nothing can free the returned object underneath it. Unlike acquire_for_audio_thread() it records nothing, so it can neither hold a retired object alive nor - the reason it exists - forge the audio thread's progress watermark and let a later reclaim() free an object the audio thread is still using.
Returns
The active object, or nullptr if publish() was never called.
void reclaim()Frees every retired object the audio thread has moved past.
Not real-time safe; call periodically off the audio thread (e.g. once per GUI frame). Must be called from the same single, consistent non-RT thread as publish() (or externally synchronized if called from more than one) - see the class-level threading contract.

