From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2008-08-06 10:59:43
Chris Knight wrote:
> On Tuesday 05 August 2008 4:34:30 pm David Abrahams wrote:
> The finite state machine I came up with for the FIX protocol was well over 50
> transitions. I implemented ours so that the from state could be boost::any
> which acts acts like '.' in regexps and I suppose means our implementation
> should be renamed kmt::nfsm. It was a zero-cost implentation as it simply
> adds one last transition to each from state's action linked-list.I was able
> to get the transition list down to 22 with that one feature. Mostly all the
> different error conditions that you want to handle gracefully in a text
> protocol originally designed in the 1980's and still used by finance
> exchanges today. <sigh>
The Boost.FSM library supports similar feature. You can use any_state
placeholder in transitions in order to tell that the transition works
for any source state.
> The other feature that I'm not sure whether FSM supports or not is static
> registering of posted event types so as to skip around run-time double
> dispatching. I suspect any implementation that seeks to provide a
> simplified/speedier interface over StateChart should support that as well.
I'm not sure what you mean by that "registering". The library does one
event dispatching if it is known at compile time that no entry in the
transition map will be triggered. If a transition map entry is
triggered, then two dispatches are done - one to deliver event to the
transition handler, and second to deliver the event to the active state.
In any case, dispatching is very efficient and is basically a call on a
function pointer that is acquired from an array by index.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk