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. | |
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.
|
static |
Returns the kind of native loop currently active, or None.
|
static |
Human-readable name for diagnostics ("cocoa", "win32", "glib", "x11", "wayland", "custom", "none").
Stable across releases — the value is documented in docs/reference/.
|
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.
|
static |
Forwards to MainThreadDispatcher::call_sync().
Returns false if no backend is registered.
|
static |
Forwards to MainThreadDispatcher::is_main_thread().
|
static |
Forwards to MainThreadDispatcher::call_async().
Returns false if no backend is registered.
|
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.
|
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.
|
static |
Clear the kind tag for a token registered via register_kind.
Safe to call with an unknown token (no-op).