Skip to content

Thread Safety

Sergei Fedorov edited this page Nov 30, 2016 · 1 revision

The afsm-based state machines can be completely thread-safe when needed and can accept events from multiple threads guaranteeing consistent order of event processing. When thread safety is not required you don't have to pay for the overhead introduced by locking mutexes.

Given a state machine definition my_fsm_def we can instantiate thread-safe and non-thread safe state machines the following way:

// Non-thread safe SM
using my_fsm_st = ::afsm::state_machine<my_fsm_def>;
// Thread-safe SM
using my_fsm_mt = ::afsm::state_machine<my_fsm_def, ::std::mutex>;

TODO Traits for supporting different kinds of mutexes.

Clone this wiki locally