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

A realtime-safe event synchronization primitive for cross-thread signaling. More...

#include <gin_realtimeevent.h>

Public Member Functions

 RealtimeEvent ()
 
 ~RealtimeEvent ()
 
void signal ()
 Signals the event, waking up any thread blocked in wait().
 
void wait ()
 Blocks the calling thread until signal() is called.
 

Detailed Description

A realtime-safe event synchronization primitive for cross-thread signaling.

RealtimeEvent provides a lightweight signaling mechanism where signal() is guaranteed to be realtime-safe (no allocations, no blocking). This is suitable for waking up non-realtime threads from audio callbacks or other time-critical contexts.

Key Features:

Usage:

// Non-realtime thread
std::thread worker([&event]() {
while (running) {
event.wait(); // Block until signaled
// ... do work ...
}
});
// Realtime thread (audio callback)
void audioCallback() {
// ... process audio ...
event.signal(); // Wake up worker (realtime-safe)
}
A lightweight 2D point class for projects that don't use juce_graphics.
Definition gin_point.h:25
A realtime-safe event synchronization primitive for cross-thread signaling.
Definition gin_realtimeevent.h:50

Platform Notes:

See also
RealtimeAsyncUpdater

Constructor & Destructor Documentation

◆ RealtimeEvent()

RealtimeEvent::RealtimeEvent ( )

◆ ~RealtimeEvent()

RealtimeEvent::~RealtimeEvent ( )

Member Function Documentation

◆ signal()

void RealtimeEvent::signal ( )

Signals the event, waking up any thread blocked in wait().

This method is realtime-safe and can be called from audio threads. Multiple calls to signal() before wait() will only wake once.

◆ wait()

void RealtimeEvent::wait ( )

Blocks the calling thread until signal() is called.

This method is NOT realtime-safe and should only be called from non-realtime threads.


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