41#include "xtc_export.h"
65typedef enum xtc_fsm_action {
72typedef struct xtc_fsm_result {
73 xtc_fsm_action_t action;
75 int64_t state_timeout_ns;
79typedef struct xtc_fsm xtc_fsm_t;
80typedef struct xtc_fsm_call xtc_fsm_call_t;
87#define XTC_FSM_IS_STATE_TIMEOUT(msg, len) ((msg) == NULL && (len) == 0)
96#define XTC_FSM_REASON_NORMAL 0
98typedef struct xtc_fsm_callbacks {
103 int (*enter)(
void *state,
int old_state,
int new_state);
111 const void *msg,
size_t len,
112 xtc_fsm_call_t *call);
115 void (*terminate)(
void *state,
int reason);
118typedef struct xtc_fsm_opts {
139XTC_API
int xtc_fsm_start(xtc_loop_t *loop,
149XTC_API
int xtc_fsm_stop(xtc_fsm_t *fsm);
155XTC_API
int xtc_fsm_join(xtc_fsm_t *fsm, int64_t timeout_ns);
158XTC_API
xtc_pid_t xtc_fsm_pid(
const xtc_fsm_t *fsm);
162XTC_API
int xtc_fsm_send(
xtc_pid_t target,
const void *ev,
size_t len);
168XTC_API
int xtc_fsm_call(
xtc_pid_t target,
169 const void *req,
size_t req_size,
170 void **out_reply,
size_t *out_size,
175XTC_API
int xtc_fsm_reply(xtc_fsm_call_t *call,
176 const void *reply,
size_t size);