Motr
M0
|
#include <sm.h>
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] |
uint64_t sd_allowed |
A bitmap of states to which transitions from this state are allowed.
This function (if non-NULL) is called by m0_sm_state_set() when the state is left.
uint32_t sd_flags |
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.
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.
const char* sd_name |
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.