[nanomsg] Re: Nanomsg state diagrams

  • From: Martin Sustrik <sustrik@xxxxxxxxxx>
  • To: Paul Colomiets <paul@xxxxxxxxxxxxxx>
  • Date: Fri, 23 Aug 2013 08:05:47 +0200

On 22/08/13 19:16, Paul Colomiets wrote:

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.

Well, if the python script could generate a simple html page that links to all the diagrams we can simply link that index page from nanomsg.org/development.html

What do you think?

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.

Sounds useful. Feel free to do that.

Martin


Other related posts: