Motr  M0
m0_sm_state_descr Struct Reference

#include <sm.h>

Collaboration diagram for m0_sm_state_descr:
Collaboration graph

Data Fields

uint32_t sd_flags
 
const char * sd_name
 
int(* sd_in )(struct m0_sm *mach)
 
void(* sd_ex )(struct m0_sm *mach)
 
bool(* sd_invariant )(const struct m0_sm *mach)
 
uint64_t sd_allowed
 
int8_t sd_trans [M0_SM_MAX_STATES]
 

Detailed Description

Description of some state machine state.

Definition at line 373 of file sm.h.

Field Documentation

◆ sd_allowed

uint64_t sd_allowed

A bitmap of states to which transitions from this state are allowed.

Note
this limits the number of states to 64, which should be more than enough. Should a need in extra complicated machines arise, this can be replaced with m0_bitmap, as the expense of making static m0_sm_state_descr more complicated.

Definition at line 422 of file sm.h.

◆ sd_ex

void(* sd_ex) (struct m0_sm *mach)

This function (if non-NULL) is called by m0_sm_state_set() when the state is left.

Definition at line 402 of file sm.h.

◆ sd_flags

uint32_t sd_flags

Flags, broadly classifying the state, taken from m0_sm_state_descr_flags.

Definition at line 378 of file sm.h.

◆ sd_in

int(* sd_in) (struct m0_sm *mach)

This function (if non-NULL) is called by m0_sm_state_set() when the state is entered.

If this function returns a non-negative number, the state machine immediately transits to the returned state (this transition includes all usual side-effects, like machine channel broadcast and invocation of the target state ->sd_in() method). This process repeats until ->sd_in() returns negative number. Such state transitions are called "chained", see "chain" UT for examples. To fail the state machine, set m0_sm::sm_rc manually and return one of M0_SDF_FAILURE states, see C_OVER -> C_LOSE transition in the "chain" UT.

Definition at line 397 of file sm.h.

◆ sd_invariant

bool(* sd_invariant) (const struct m0_sm *mach)

Invariant that must hold while in this state. Specifically, this invariant is checked under the state machine lock once transition to this state completed, checked under the same lock just before a transition out of the state is about to happen and is checked (under the lock) whenever a m0_sm call finds the target state machine in this state.

If this field is NULL, no invariant checks are done.

Definition at line 413 of file sm.h.

◆ sd_name

const char* sd_name

Human readable state name for debugging. This field is NULL for "invalid" states, which state machine may never enter.

Definition at line 383 of file sm.h.

◆ sd_trans

int8_t sd_trans[M0_SM_MAX_STATES]

An index map of allowed transitions from this state. The index here is the state to which transition is allowed. The value maps to the index in transitions array (m0_sm_conf::scf_trans). The value of ~0 means that transition is not allowed. This field is constructed at run-time in m0_sm_conf_init() routine, which must be called before state machine with this configuration can be constructed.

Definition at line 433 of file sm.h.


The documentation for this struct was generated from the following file: