xtc_app(3)

---

xtc_app(3)

OTP-style application container

XTC_APP(3) Library Functions Manual XTC_APP(3)

xtc_app_create, xtc_app_destroy, xtc_app_start, xtc_app_run, xtc_app_stop, xtc_app_loop, xtc_app_exec, xtc_app_registryOTP-style application container

#include <xtc.h>
#include <xtc_app.h>

int
xtc_app_create(const xtc_app_opts_t *opts, xtc_app_t **out);

void
xtc_app_destroy(xtc_app_t *app);

int
xtc_app_start(xtc_app_t *app, const xtc_child_spec_t *children, int n_children);

int
xtc_app_run(xtc_app_t *app);

int
xtc_app_stop(xtc_app_t *app);

xtc_loop_t *
xtc_app_loop(const xtc_app_t *app);

xtc_exec_t *
xtc_app_exec(const xtc_app_t *app);

xtc_reg_t *
xtc_app_registry(const xtc_app_t *app);

xtc_app is the L4 application container -- a root supervisor plus a process registry plus lifecycle plumbing. Models OTP's ‘application’ concept.

An app owns:

  • A loop (created if not supplied).
  • A root supervisor with the configured children.
  • A process registry where children can find each other by name (see xtc_reg(3)).

Typical usage:

xtc_app_opts_t opts = XTC_APP_OPTS_DEFAULT;
opts.name = "my_service";
opts.sup.strategy = XTC_SUP_ONE_FOR_ONE;

xtc_app_t *app;
xtc_app_create(&opts, &app);

xtc_child_spec_t kids[] = {
    { .name = "listener",  .fn = listener_proc, .arg = NULL,
      .policy = XTC_RESTART_PERMANENT },
    { .name = "metrics",   .fn = metrics_proc,  .arg = NULL,
      .policy = XTC_RESTART_TRANSIENT },
};
xtc_app_start(app, kids, 2);
xtc_app_run(app);              /* blocks until app stops */
xtc_app_destroy(app);

() returns the application's event loop and () its process registry. () returns the underlying xtc_exec(3) executor the application runs its loop on.

The current implementation is single-loop; multi-loop apps spawn xtc_exec(3) directly. Future revisions may grow N-loop apps for thread-per- core scaling.

xtc_supervisor(3), xtc_reg(3), xtc_loop(3), xtc(7)

Appeared in xtc 0.1.

May 28, 2026 Debian

View the mdoc source