Comment

Comment by nivertech

Sometimes you need just an FSM without attached process/thread with mailbox/queue (i.e. passive FSM). Then you have an API to dispatch events and query current state.

For example if you have gen_server using FSM, with gen_fsm you will have 2 processes. If there was passive FSM module, you would save 1 process and handle twice as many simultaneous clients.

Some examples from boost statechart library:

http://www.boost.org/doc/libs/1_34_0/libs/statechart/doc/tut...

  #include <boost/statechart/transition.hpp>
  
  // ...
  
  int main()
  {
    StopWatch myWatch;
    myWatch.initiate();
    myWatch.process_event( EvStartStop() );
    myWatch.process_event( EvStartStop() );
    myWatch.process_event( EvStartStop() );
    myWatch.process_event( EvReset() );
    return 0;
  }
parent nivertech 16 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton