Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
pulp::events::MessageLoopIntegration Class Reference

Cross-platform introspection of the active main loop. More...

#include <message_loop_integration.hpp>

Static Public Member Functions

static MainLoopKind active_kind ()
 Returns the kind of native loop currently active, or None.
static std::string_view active_name ()
 Human-readable name for diagnostics ("cocoa", "win32", "glib", "x11", "wayland", "custom", "none").
static bool available ()
 Convenience: any non-None backend is registered.
static bool is_main_thread ()
 Forwards to MainThreadDispatcher::is_main_thread().
static bool post (Task task)
 Forwards to MainThreadDispatcher::call_async().
static bool call_sync (Task task)
 Forwards to MainThreadDispatcher::call_sync().
static MainLoopPumpResult pump_main_loop_for (std::chrono::milliseconds max_duration)
 Service the native process main loop for at most max_duration.
static void register_kind (MainThreadDispatcher::Token token, MainLoopKind kind)
 Register the kind tag for a custom backend.
static void unregister_kind (MainThreadDispatcher::Token token)
 Clear the kind tag for a token registered via register_kind.

Detailed Description

Cross-platform introspection of the active main loop.

The introspection and dispatch methods are thread-safe. Backends register themselves with the process-wide MainThreadDispatcher and the returned MainLoopKind follows whatever the most-recent active registration is. pump_main_loop_for() is deliberately main-thread-only.

Member Function Documentation

◆ active_kind()

MainLoopKind pulp::events::MessageLoopIntegration::active_kind ( )
static

Returns the kind of native loop currently active, or None.

◆ active_name()

std::string_view pulp::events::MessageLoopIntegration::active_name ( )
static

Human-readable name for diagnostics ("cocoa", "win32", "glib", "x11", "wayland", "custom", "none").

Stable across releases — the value is documented in docs/reference/.

◆ available()

bool pulp::events::MessageLoopIntegration::available ( )
static

Convenience: any non-None backend is registered.

Equivalent to active_kind() != MainLoopKind::None and forwards to the MainThreadDispatcher::has_backend() check the underlying implementation uses.

◆ call_sync()

bool pulp::events::MessageLoopIntegration::call_sync ( Task task)
static

Forwards to MainThreadDispatcher::call_sync().

Returns false if no backend is registered.

◆ is_main_thread()

bool pulp::events::MessageLoopIntegration::is_main_thread ( )
static

◆ post()

bool pulp::events::MessageLoopIntegration::post ( Task task)
static

Forwards to MainThreadDispatcher::call_async().

Returns false if no backend is registered.

◆ pump_main_loop_for()

MainLoopPumpResult pulp::events::MessageLoopIntegration::pump_main_loop_for ( std::chrono::milliseconds max_duration)
static

Service the native process main loop for at most max_duration.

Apple hosts use this to advance dispatch-main, CFRunLoop, Cocoa, XPC, and timer work while rendering headlessly. It must be called from the process main/control thread, never from an audio callback. A zero or negative duration performs a non-blocking poll. Other platforms return Unsupported until they grow an equivalent bounded implementation.

This reports event-loop progress only. It is not a plug-in readiness or licensing signal; callers remain responsible for their own warm-up and settle policy.

◆ register_kind()

void pulp::events::MessageLoopIntegration::register_kind ( MainThreadDispatcher::Token token,
MainLoopKind kind )
static

Register the kind tag for a custom backend.

Call this AFTER MainThreadDispatcher::register_backend() returns a token, so the introspection layer reports the correct value. Pulp's own platform backends (Cocoa, Win32, GLib, ...) call this internally — third-party SDL / Tauri-style integrations should call it directly with MainLoopKind::Custom.

token is the value returned by MainThreadDispatcher::register_backend. unregister_kind(token) removes the tag; if you forget, the tag stays until the process ends but the dispatcher's own teardown still cleans up the actual backend.

◆ unregister_kind()

void pulp::events::MessageLoopIntegration::unregister_kind ( MainThreadDispatcher::Token token)
static

Clear the kind tag for a token registered via register_kind.

Safe to call with an unknown token (no-op).


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