Motr  M0
m0_fom_simple Struct Reference

#include <fom_simple.h>

Collaboration diagram for m0_fom_simple:
Collaboration graph

Data Fields

struct m0_fom si_fom
 
int(* si_tick )(struct m0_fom *fom, void *data, int *phase)
 
void * si_data
 
size_t si_locality
 
struct m0_fom_type si_type
 
void(* si_free )(struct m0_fom_simple *sfom)
 

Detailed Description

Simple fom executes m0_fom_simple::si_tick() in each tick.

Simplest m0_fom_simple::si_tick() is created by calling m0_fom_simple_post() with NULL "conf" parameter. Such call initialises a fom with the following trivial state machine:

*    +-----+
*    |     |
*    V     |
*   INIT---+
*    |
*    |
*    V
*  FINISH
* 

The useful work is done by m0_fom_simple::si_tick() function (initialised to the "tick" argument of m0_fom_simple_post()) in INIT state. To terminate the fom, m0_fom_simple::si_tick() should return a negative value.

Typical m0_fom_simple::si_tick() function in such case would look like:

int foo_tick(struct m0_fom *fom, struct foo *f, int *__unused)
{
switch (foo->f_subphase) {
case SUBPHASE_0:
do_something_0(f);
foo->f_subphase = SUBPHASE_1;
case SUBPHASE_1:
do_something_1(f);
foo->f_subphase++;
return M0_FSO_WAIT;
...
case SUBPHASE_N:
// terminate simple fom
return -1;
}
}

That is, m0_fom_simple::si_tick() is very similar to m0_fom_ops::fo_tick(), except that it gets an additional "data" parameter, originally passed by the user to m0_fom_simple_post() and uses some fom-specific "subphase" instead of fom phase.

Passing a non-NULL conf to m0_fom_simple_post() creates a "semisimple" fom with the user-supplied configuration. Such fom can use usual fom phases to keep track of it current state. For a semisimple fom, current phase is passed in "phase" parameter to m0_fom_simple::si_tick().

A typical semisimple m0_fom_simple::si_tick() looks like:

int foo_tick(struct m0_fom *fom, struct foo *f, int *phase)
{
switch (*phase) {
case PHASE_0:
do_something_0(f);
*phase = PHASE_1;
case PHASE_1:
do_something_1(f);
(*phase)++;
return M0_FSO_WAIT;
...
case PHASE_N:
return -1;
}
}

Note that the type of the second parameter can be different from void *, see M0_FOM_SIMPLE_POST().

Definition at line 119 of file fom_simple.h.

Field Documentation

◆ si_data

void* si_data

User provided data, passed to ->si_tick().

Definition at line 123 of file fom_simple.h.

◆ si_fom

struct m0_fom si_fom

Definition at line 120 of file fom_simple.h.

◆ si_free

void(* si_free) (struct m0_fom_simple *sfom)

Cleanup function pointer called by fom_simple_fini()

Definition at line 129 of file fom_simple.h.

◆ si_locality

size_t si_locality

User supplied locality.

Definition at line 125 of file fom_simple.h.

◆ si_tick

int(* si_tick) (struct m0_fom *fom, void *data, int *phase)

Definition at line 121 of file fom_simple.h.

◆ si_type

struct m0_fom_type si_type

Embedded fom type for "semisimple" fom.

Definition at line 127 of file fom_simple.h.


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