75 if(!
f.get().valid()) {
76 zth_dbg(thread,
"zth_run() fiber did not exit normally");
79#ifdef __cpp_exceptions
81 zth_dbg(thread,
"zth_run() caught exception with errno %d", e.
code);
83 }
catch(std::exception
const& e) {
84 zth_dbg(thread,
"zth_run() caught exception: %s", e.what());
87 zth_dbg(thread,
"zth_run() caught zth::exception");
91 zth_dbg(thread,
"zth_run() caught unknown exception");
109 int res = EXIT_SUCCESS;
121 if(!
f.get().valid()) {
122 zth_dbg(thread,
"main_fiber() did not exit normally");
127#ifdef __cpp_exceptions
129 zth_dbg(thread,
"main() caught exception with errno %d", e.
code);
131 }
catch(std::exception
const& e) {
132 zth_dbg(thread,
"main() caught exception: %s", e.what());
135 zth_dbg(thread,
"main() caught zth::exception");
139 zth_dbg(thread,
"main() caught unknown exception");
143 zth_dbg(thread,
"main() returns %d", res);
static safe_ptr< singleton_type >::type instance() noexcept
Return the only instance of T within this thread.
The class that manages the fibers within this thread.
void run(TimeInterval const &duration=TimeInterval())
int main_fiber(int argc, char **argv)
#define zth_config(name)
Checks if the given zth::Config field is enabled.
fiber_type< F >::fiber fiber(F &&f, Args &&... args)
Create and start a new fiber.
#define zth_dbg(group, fmt, a...)
Debug printf()-like function.
struct zth_init_entry * zth_init_tail
void zth_init()
Perform one-time global initialization of the Zth library.
int zth_run(void(fiber)(void *), void *arg)
Start Zth given the given fiber function.
struct zth_init_entry const * zth_init_head
int zth_main(int argc, char **argv)
Default main function that runs main_fiber.
int zth_postdeinit()
Initialization function to be called by the default-supplied main(), just before shutting down.
void zth_preinit()
Initialization function to be called by the default-supplied main(), before doing anything else.
static bool const EnablePerfEvent
Enable (but not necessarily record) perf.
static bool const EnableStackWaterMark
When true, enable stack watermark to detect maximum stack usage.
Base exception class for Zth exceptions.
The future returned by a fiber.
Change the name of a fiber returned by zth_async.
struct zth_init_entry const * next
zth_init_entry(void(*f_)(void), zth_init_entry const *next_) noexcept
#define likely(expr)
Marks the given expression to likely be evaluated to true.