STX  1.0.0
hook.h
Go to the documentation of this file.
1 
30 #pragma once
31 
32 #include <atomic>
33 
34 #include "stx/panic.h"
35 
58 
60 
61 #if defined(STX_VISIBLE_PANIC_HOOK)
62 constexpr bool kPanicHookVisible = true;
63 #else
64 constexpr bool kPanicHookVisible = false;
65 #endif
66 
67 // multiple threads can try to modify/read the hook at once.
68 using PanicHook = decltype(panic_handler)*;
69 using AtomicPanicHook = std::atomic<PanicHook>;
70 
71 namespace this_thread {
72 
79 [[nodiscard]] STX_EXPORT bool is_panicking() noexcept;
80 } // namespace this_thread
81 
90 [[nodiscard]] STX_EXPORT bool panic_hook_visible() noexcept;
91 
102 [[nodiscard]]
103 #if defined(STX_VISIBLE_PANIC_HOOK)
105 #else
106 STX_LOCAL
107 #endif
108 
109  bool
110  attach_panic_hook(PanicHook hook) noexcept;
111 
123 [[nodiscard]]
124 #if defined(STX_VISIBLE_PANIC_HOOK)
126 #else
127 STX_LOCAL
128 #endif
129 
130  bool
131  take_panic_hook(PanicHook* hook) noexcept;
132 
STX_EXPORT bool is_panicking() noexcept
STX_LOCAL bool attach_panic_hook(PanicHook hook) noexcept
STX_LOCAL bool take_panic_hook(PanicHook *hook) noexcept
void panic_handler(std::string_view const &info, ReportPayload const &payload, SourceLocation const &location) noexcept
constexpr bool kPanicHookVisible
Definition: hook.h:64
#define STX_LOCAL
Definition: config.h:287
STX_EXPORT bool panic_hook_visible() noexcept
decltype(panic_handler) * PanicHook
Definition: hook.h:68
#define STX_END_NAMESPACE
Definition: config.h:329
#define STX_BEGIN_NAMESPACE
Definition: config.h:325
#define STX_EXPORT
Definition: config.h:286
std::atomic< PanicHook > AtomicPanicHook
Definition: hook.h:69