22#include "xtc_export.h"
36typedef enum xtc_restart_strategy {
37 XTC_SUP_ONE_FOR_ONE = 0,
38 XTC_SUP_ONE_FOR_ALL = 1,
39 XTC_SUP_REST_FOR_ONE = 2,
40 XTC_SUP_SIMPLE_OFO = 3
41} xtc_restart_strategy_t;
43typedef enum xtc_restart_policy {
44 XTC_RESTART_PERMANENT = 0,
45 XTC_RESTART_TRANSIENT = 1,
46 XTC_RESTART_TEMPORARY = 2
47} xtc_restart_policy_t;
54typedef struct xtc_child_spec {
59 xtc_restart_policy_t policy;
69#define XTC_CHILD_SPEC_INIT { .size = sizeof(xtc_child_spec_t) }
71typedef struct xtc_sup_opts {
73 xtc_restart_strategy_t strategy;
76 struct xtc_exec *exec;
88#define XTC_SUP_OPTS_DEFAULT { \
89 .size = sizeof(xtc_sup_opts_t), \
90 .strategy = XTC_SUP_ONE_FOR_ONE, \
92 .period_ns = 5LL * 1000 * 1000 * 1000, \
97typedef struct xtc_supervisor xtc_supervisor_t;
114XTC_API
int xtc_sup_start(xtc_loop_t *loop,
118 xtc_supervisor_t **out_sup);
125XTC_API
int xtc_sup_stop(xtc_supervisor_t *sup);
133XTC_API
int xtc_sup_add_child(xtc_supervisor_t *sup,
const xtc_child_spec_t *spec,
140int xtc_sup_join(xtc_supervisor_t *sup, int64_t timeout_ns);
142XTC_API
int xtc_sup_n_children(
const xtc_supervisor_t *sup);
143XTC_API
int xtc_sup_n_alive(
const xtc_supervisor_t *sup);
144XTC_API
int xtc_sup_n_restarts(
const xtc_supervisor_t *sup);
145XTC_API
int xtc_sup_alive(
const xtc_supervisor_t *sup);