tkem / fsmlite

Lightweight finite state machine framework for C++11
MIT License
161 stars 25 forks source link

Document/assert behavior of process_event() from actions/guards #5

Closed tkem closed 6 years ago

tkem commented 9 years ago

process_event() must not be called from within an action or guard. Maybe assert this with #ifndef NDEBUG (flag set on entry and cleared on exit).

tkem commented 9 years ago

Turns out <cassert> is not required for freestanding implementations.

tkem commented 6 years ago

Better than plain assert would probably be throwing a std::logic_error. For systems that don't use exceptions, this could still be wrapped in an #ifndef NDEBUG block. Also a RAII-type guard object should be used to set/clear the processing flag, to handle exceptions intentionally thrown by actions.