5#include <portals/detail/current_scene.hpp>
6#include <portals/managed_diagnostics.hpp>
8namespace portals::ui::detail {
11enum class SetupFailureEvent {
19using SetupFailureSink = void (*)(
void *, SetupFailureEvent, ManagedError *,
const void *)
noexcept;
22class SetupFailureTicket {
24 SetupFailureTicket() =
default;
25 SetupFailureTicket(
const SetupFailureTicket &) =
delete;
26 SetupFailureTicket &operator=(
const SetupFailureTicket &) =
delete;
30 send(SetupFailureEvent::NOTIFY);
35 send(SetupFailureEvent::END_ATTEMPT);
41 SetupFailureTicket(std::weak_ptr<void> owner, SetupFailureSink sink,
const void *attempt) noexcept
42 : owner_(std::move(owner)), sink_(sink), attempt_(attempt) {
45 void send(SetupFailureEvent event)
const noexcept {
46 if (
const auto owner = owner_.lock(); owner && sink_) {
47 sink_(owner.get(), event,
nullptr, attempt_);
51 std::weak_ptr<void> owner_;
52 SetupFailureSink sink_{};
53 const void *attempt_{};
63 SetupFailureScope(std::weak_ptr<void> owner, SetupFailureSink sink,
const char *execution) noexcept
64 : owner_(std::move(owner)), sink_(sink), execution_(execution), previous_(current_) {
75 if (
const auto owner = owner_.lock(); owner && sink_) {
76 sink_(owner.get(), SetupFailureEvent::END_SCOPE,
nullptr,
nullptr);
88 auto *scope = current_;
90 if (!scope || !scope->sink_) {
94 const auto owner = scope->owner_.lock();
102 scope->sink_(owner.get(), SetupFailureEvent::LATCH, &failure, attempt);
110 std::weak_ptr<void> owner_;
111 SetupFailureSink sink_{};
112 const char *execution_{};
122template <
class Callback>
auto currentSceneCallback(std::weak_ptr<SceneAnchor> scene, Callback &&callback) {
Facade-aware callback storage; invocation publishes weak ownership, retirement masks its caller.
Definition current_scene.hpp:69
Allocation-free UI execution publication; an empty scope suspends the caller's scene.
Definition current_scene.hpp:37
Suspend an unrelated setup collector during an independently owned callback.
Definition current_scene.hpp:16
Allocation-free current-thread setup context; nested independent scopes restore their parent.
Definition setup_failure.hpp:57
SetupFailureScope(std::weak_ptr< void > owner, SetupFailureSink sink, const char *execution) noexcept
Definition setup_failure.hpp:63
static SetupFailureTicket latch(ManagedError &failure, const void *attempt=nullptr) noexcept
Definition setup_failure.hpp:87
Stack-local entered-report identity, valid only during one synchronous collector call.
Definition setup_failure.hpp:22
~SetupFailureTicket()
Revoke the borrowed attempt identity before its stack storage retires.
Definition setup_failure.hpp:34
void notifying() const noexcept
Mark notification before the observer can reenter; no user callback runs here.
Definition setup_failure.hpp:29
Original error plus independent runner/restoration and cleanup failures.
Definition managed_diagnostics.hpp:62
bool setupStopped
A scoped short failure stopped subsequent setup/run after the current callback returned.
Definition managed_diagnostics.hpp:86
const char * execution
Library static-storage facade boundary label; does not replace the original phase.
Definition managed_diagnostics.hpp:85