Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
plugin_main_thread.hpp
Go to the documentation of this file.
1#pragma once
2
3// Plugin-mode main-thread cooperation.
4//
5// Standalone macOS apps register a Cocoa `MainThreadDispatcher` backend from
6// `WindowHost::create()` so cross-subsystem work can post to
7// `dispatch_get_main_queue()`. In plugin mode (AU v3 / VST3 / CLAP loaded
8// inside a DAW like Logic / Cubase / Bitwig), there is no Pulp window — the DAW
9// owns the main `NSApplication`/`CFRunLoop`. Without an explicit registration,
10// `MainThreadDispatcher::call_async` returns false and adapter-side code that
11// asks "please run this on the host's main thread" no-ops.
12//
13// The helpers in this header let format adapters and plugin instance owners
14// register a process-wide Cocoa backend at instantiation time and unregister
15// it at teardown. On non-macOS platforms the calls degrade to no-ops so
16// adapter code can call them unconditionally; the dispatcher then simply
17// stays in its "no backend" state on those platforms (Windows / Linux own
18// their own message-loop integration paths).
19//
20// Reference-counted under the hood — call register_plugin_backend() once
21// per loaded plugin instance, and `unregister_plugin_backend()` once on
22// teardown. The first register installs a backend; subsequent registers bump
23// the refcount; the last unregister removes the backend. Safe to call from
24// any thread.
25
27
28namespace pulp::events {
29
37
42
47
48} // namespace pulp::events
std::uint64_t Token
Definition main_thread_dispatcher.hpp:24
Definition child_process_manager.hpp:18
MainThreadDispatcher::Token register_plugin_backend()
Register a process-wide Cocoa main-thread backend for plugin-mode use.
bool unregister_plugin_backend(MainThreadDispatcher::Token token)
Tear down a backend installed via register_plugin_backend().
bool plugin_backend_available()
Whether the host platform has a plugin-mode backend implementation.