I have a setup with 2 threads.
One thread contains a boost sml state machine that can perform actual work (Thread 1).
Another thread that can receive external goal requests (Thread 2).
The class in thread 2 can set goals on the state machine in thread 1, but only when the state machine is in a specific subset of states.
If I understand the documentation correctly then I can make the state_machine thread safe by providing sml::thread_safe<std::recursive_mutex>.
Now I assume that this will allow me to call process_event() and is() in a thread safe way.
However in a check like this:
using namespace boost::sml;
return (state_machine_->is("State1"_s) || state_machine_->is("State2"_s));
The lock would be released in between check 1 and 2 which is not desirable.
Is it possible to lock the mutex used by the state_machine_ from the outside to maintain the lock for the entire call?