42#include "xtc_export.h"
66typedef enum xtc_fsm_action {
73typedef struct xtc_fsm_result {
74 xtc_fsm_action_t action;
76 int64_t state_timeout_ns;
80typedef struct xtc_fsm xtc_fsm_t;
81typedef struct xtc_fsm_call xtc_fsm_call_t;
88#define XTC_FSM_IS_STATE_TIMEOUT(msg, len) ((msg) == NULL && (len) == 0)
97#define XTC_FSM_REASON_NORMAL 0
99typedef struct xtc_fsm_callbacks {
106 int (*enter)(
void *state,
int old_state,
int new_state);
114 const void *msg,
size_t len,
115 xtc_fsm_call_t *call);
118 void (*terminate)(
void *state,
int reason);
121#define XTC_FSM_CALLBACKS_INIT { .size = sizeof(xtc_fsm_callbacks_t) }
123typedef struct xtc_fsm_opts {
129#define XTC_FSM_OPTS_INIT { .size = sizeof(xtc_fsm_opts_t) }
147XTC_API
int xtc_fsm_start(xtc_loop_t *loop,
157XTC_API
int xtc_fsm_stop(xtc_fsm_t *fsm);
164XTC_API
int xtc_fsm_join(xtc_fsm_t *fsm, int64_t timeout_ns);
167XTC_API
xtc_pid_t xtc_fsm_pid(
const xtc_fsm_t *fsm);
171XTC_API
int xtc_fsm_send(
xtc_pid_t target,
const void *ev,
size_t len);
177XTC_API
int xtc_fsm_call(
xtc_pid_t target,
178 const void *req,
size_t req_size,
179 void **out_reply,
size_t *out_size,
184XTC_API
int xtc_fsm_reply(xtc_fsm_call_t *call,
185 const void *reply,
size_t size);