关于PVFS状态机的声明和定义---src/common/misc/state-machine.h

/* State machine control block - one per running instance of a state
 * machine
 */
typedef struct PINT_smcb
{
    /* state machine execution variables */
    int stackptr;
    struct PINT_state_s *current_state;
    struct PINT_state_stack_s state_stack[PINT_STATE_STACK_SIZE];

    struct qlist_head frames;  /* circular list of frames */
    int base_frame;   /* index of current base frame */
    int frame_count;  /* number of frames in list */

    /* usage specific routinet to look up SM from OP */
    struct PINT_state_machine_s *(*op_get_state_machine)(int);
    /* state machine context and control variables */
    int op; /* this field externally indicates type of state machine */
    PVFS_id_gen_t op_id; /* unique ID for this operation */
    struct PINT_smcb *parent_smcb; /* points to parent smcb or NULL */
    int op_terminate; /* indicates SM is ready to terminate */
    int op_cancelled; /* indicates SM operation was cancelled */
    int children_running; /* the number of child SMs running */
    int op_completed;  /* indicates SM operation was added to completion Q */
    /* add a lock here */
    job_context_id context; /* job context when waiting for children */
    int (*terminate_fn)(struct PINT_smcb *, job_status_s *);
    void *user_ptr; /* external user pointer */
    int immediate; /* specifies immediate completion of the state machine */
} PINT_smcb;

#define PINT_SET_OP_COMPLETE do{PINT_smcb_set_complete(smcb);} while (0)

struct PINT_state_machine_s
{
    const char *name;
    struct PINT_state_s *first_state;
};

struct PINT_state_s
{
    const char *state_name;
    struct PINT_state_machine_s *parent_machine;
    enum PINT_state_code flag;
    union
    {
        int (*func)(struct PINT_smcb *, job_status_s *);
        struct PINT_state_machine_s *nested;
    } action;
    struct PINT_pjmp_tbl_s *pjtbl;
    struct PINT_tran_tbl_s *trtbl;
};

struct PINT_pjmp_tbl_s              
{
    int return_value;
    enum PINT_state_code flag;
    struct PINT_state_machine_s *state_machine;
};

struct PINT_tran_tbl_s
{
    int return_value;
    enum PINT_state_code flag;
    struct PINT_state_s *next_state;
};



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值