In-process notifier. More...
#include <environment.hpp>
Classes | |
| class | Token |
| RAII subscription. Drop to unsubscribe. More... | |
Public Types | |
| using | Listener |
Public Member Functions | |
| EnvironmentState | snapshot () const |
| Snapshot the current state. Safe from any thread. | |
| Token | subscribe (Listener listener) |
| Subscribe to changes. | |
| void | publish (const EnvironmentState &next) |
| Push a new state. | |
Static Public Member Functions | |
| static Environment & | instance () |
| Get the process singleton. | |
| static void | inject_for_test (const EnvironmentState &state) |
| Replace the singleton state and notify listeners. | |
| static void | reset_for_test () |
| Reset the singleton to defaults and remove every listener. | |
In-process notifier.
Listeners survive until the returned token is destroyed (RAII subscription pattern, same as runtime::Logger).
The notifier is intentionally a singleton — there's exactly one OS reporting these signals per process. Tests can call inject_for_test to drive the singleton without a real platform adapter.
|
static |
Replace the singleton state and notify listeners.
Used by unit tests to simulate platform events without a real OS callback.
|
static |
Get the process singleton.
| void pulp::platform::Environment::publish | ( | const EnvironmentState & | next | ) |
Push a new state.
Computes EnvironmentChange against the prior snapshot and dispatches to every listener. Intended for platform adapter code; tests use inject_for_test (which forwards here after taking the test mutex).
|
static |
Reset the singleton to defaults and remove every listener.
Tests call this in TEST_CASE setup so prior tests don't leak listeners or stale state.
| EnvironmentState pulp::platform::Environment::snapshot | ( | ) | const |
Snapshot the current state. Safe from any thread.
Subscribe to changes.
The callback fires after publish returns the new state. The returned token unsubscribes on destruction.