Hi Martin, On Thu, Aug 22, 2013 at 9:21 AM, Martin Sustrik <sustrik@xxxxxxxxxx> wrote: > Super-cool! > > Where should we store such generated documentation? In the repo itself? > Website? Elsewhere? > I don't think keeping generated pictures in git is nice (and dot files are not useful either). But publishing them on the website would be cool. > >> It seems that shutdown code is handled by a bunch of if statements at >> the start of handlers, instead of switches. Why it's handled in a >> special way? > > > I wanted to blog about this but haven't have found time so far. Let me > explain in short: > > State machine can have arbitrary number of states. In each state some > sub-components are initialised some are not initialised. > > State machine shutdown (as if nn_close() is called) can occur in any state, > thus, each "normal" state would have to have a chain of attached "shutdown" > states to stop all the sub-components cleanly. > > That increases the number of states in thr state machine quadratically. > > To avoid proliferation of states, I've introduced special handling for > shutdown, which simply stops anything that's still running, not depending on > the initial state of the state machine (see attached picture). > Thanks. From the first sight it looked weird. But after looking at several shutdown routines, it now looks super-clear. It would be nice to separate this code into a block `if (self->state == NN_FSM_STATE_STOPPING)` or a function or something, so that it's clear that when you start shutting down, you never escape from this series of shutdown states. -- Paul