Boost msm中的线程安全 [英] Thread safety in Boost msm

查看:188
本文介绍了Boost msm中的线程安全的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来提升元状态库的人.我正在构建一个必须使用msm的应用程序.

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

我的应用程序有两个线程,它们在其中使用相同的msm对象作为共享资源.现在,如果两个线程都在同一个msm对象上调用process_event,则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?

欢迎提出任何想法.

推荐答案

引用克里斯托夫·亨利(Christophe Henry),当您在Boost.Users列表中询问时,他回答了这个问题:

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

msm与STL容器一样具有线程安全性:不是. 不同的线程不应在同一状态机对象上调用process_event. 这意味着您必须通过同步机制将对对象的调用序列化.

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.

这篇关于Boost msm中的线程安全的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆