Gin
Loading...
Searching...
No Matches
Public Member Functions | List of all members
RealtimeAsyncUpdater Class Referenceabstract

An asynchronous update dispatcher that bypasses the message queue. More...

#include <gin_realtimeasyncupdater.h>

Public Member Functions

 RealtimeAsyncUpdater ()
 Creates a RealtimeAsyncUpdater.
 
virtual ~RealtimeAsyncUpdater ()
 Destructor.
 
void triggerAsyncUpdate ()
 Triggers an asynchronous update.
 
void cancelPendingUpdate () noexcept
 Cancels any pending update.
 
void handleUpdateNowIfNeeded ()
 Handles the update immediately if one is pending.
 
bool isUpdatePending () const noexcept
 Checks if an update is currently pending.
 
virtual void handleAsyncUpdate ()=0
 Called asynchronously when an update is triggered.
 

Detailed Description

An asynchronous update dispatcher that bypasses the message queue.

Similar to juce::AsyncUpdater, but uses a dedicated background thread instead of the message queue. This makes it suitable for real-time applications where the message queue might introduce unacceptable latency or where the message thread might be blocked.

Multiple calls to triggerAsyncUpdate() are coalesced - if called multiple times before handleAsyncUpdate() runs, it will only be called once.

See also
triggerAsyncUpdate, handleAsyncUpdate, cancelPendingUpdate

Constructor & Destructor Documentation

◆ RealtimeAsyncUpdater()

RealtimeAsyncUpdater::RealtimeAsyncUpdater ( )

◆ ~RealtimeAsyncUpdater()

virtual RealtimeAsyncUpdater::~RealtimeAsyncUpdater ( )
virtual

Destructor.

Cancels any pending updates.

Member Function Documentation

◆ triggerAsyncUpdate()

void RealtimeAsyncUpdater::triggerAsyncUpdate ( )

Triggers an asynchronous update.

Schedules handleAsyncUpdate() to be called on a background thread. Multiple calls before the update executes are coalesced into a single callback. This method is thread-safe and can be called from any thread, including real-time audio threads.

◆ cancelPendingUpdate()

void RealtimeAsyncUpdater::cancelPendingUpdate ( )
noexcept

Cancels any pending update.

Prevents handleAsyncUpdate() from being called if it hasn't executed yet. This is thread-safe.

◆ handleUpdateNowIfNeeded()

void RealtimeAsyncUpdater::handleUpdateNowIfNeeded ( )

Handles the update immediately if one is pending.

If an update has been triggered but not yet executed, this will execute it immediately on the current thread and cancel the pending background execution.

◆ isUpdatePending()

bool RealtimeAsyncUpdater::isUpdatePending ( ) const
noexcept

Checks if an update is currently pending.

Returns
true if triggerAsyncUpdate() has been called and handleAsyncUpdate() hasn't executed yet

◆ handleAsyncUpdate()

virtual void RealtimeAsyncUpdater::handleAsyncUpdate ( )
pure virtual

Called asynchronously when an update is triggered.

Override this method to perform your update logic. This will be called on a dedicated background thread (not the message thread).


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