Gin
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
LambdaAsyncUpdater Class Reference

Async updater that calls a std::function callback instead of requiring virtual override. More...

#include <gin_asyncutilities.h>

Inherits juce::AsyncUpdater.

Public Member Functions

 LambdaAsyncUpdater (std::function< void()> func)
 

Public Attributes

std::function< void()> onAsyncUpdate
 

Detailed Description

Async updater that calls a std::function callback instead of requiring virtual override.

LambdaAsyncUpdater provides a more convenient alternative to juce::AsyncUpdater by accepting a lambda or std::function for the async callback. This is useful for safely triggering message-thread operations from other threads without creating a full subclass.

Key Features:

The onAsyncUpdate function is called on the message thread when triggerAsyncUpdate() is called from any thread. Multiple calls are coalesced into a single callback.

Thread Safety:

Usage:

// Create with lambda (runs on message thread)
// This runs on the message thread
});
// Trigger from audio thread or background thread
// Process audio...
updater.triggerAsyncUpdate(); // Safely posts to message thread
}
// Multiple triggers coalesce into one callback
updater.triggerAsyncUpdate();
updater.triggerAsyncUpdate(); // Only one callback will occur
Async updater that calls a std::function callback instead of requiring virtual override.
Definition gin_asyncutilities.h:115
A lightweight 2D point class for projects that don't use juce_graphics.
Definition gin_point.h:25
See also
juce::AsyncUpdater, LambdaTimer, callOnMainThreadBlocking

Constructor & Destructor Documentation

◆ LambdaAsyncUpdater()

LambdaAsyncUpdater::LambdaAsyncUpdater ( std::function< void()>  func)

Member Data Documentation

◆ onAsyncUpdate

std::function<void()> LambdaAsyncUpdater::onAsyncUpdate

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