Thread safety in Boost msm

2019-07-21 09:12发布

问题:

I am new to boost meta state library. I am building one app, where I have to use msm.

My application has two threads, where they use same msm object as a shared resources. Now will the msm be thread safe if both threads call process_event on the same msm object?

Any idea is welcome.

回答1:

Quoting Christophe Henry, who answered this when you asked it on the Boost.Users list:

msm is as thread-safe as a STL container: it's not. Different threads should not call process_event on the same state machine object. This means you'll have to serialize your calls to the object through a synchronization mechanism.