c++ - 从 boost::thread 访问对象
问题描述
在我的程序中,我使用以下方法启动循环函数boost::thread
:
代码是这样的:
void MyClass::StartSim()
{
_thread = boost::thread(boost::bind(&MyClass::BoostTick, boost::ref(*this)));
}
void MyClass::BoostTick()
{
while (!_shutdown)
{
// do something
}
}
并且工作正常......现在我有一个这样的功能:
Ray MyClass:GetRay()
{
// here I use an object that is used inside the while loop
}
但我有例外...
有没有办法避免异常?
提前致谢
解决方案
推荐阅读
- java - 试图在 intellij jre11 上运行 javafx 程序
- django - 为生产中的窗口配置 Django 通道
- android - Android Studio 的目录在哪里?
- c - “C 标准对不同数据类型的数值范围设置了下限,但没有上限”?
- sql-server - 从 AWS RDS MS SQL Server 中的现有 SQL Server 数据库 bacpac 文件创建数据库时出错
- asp.net - 网站上某些页面的 asp.net 无 cookie
- excel - 使用 Powershell 将图表从 Excel 复制到 Word
- mysql - 使用 concat 让用户加入
- eclipse - 找不到 Eclipse JDK 11 QName
- wowza - 如何对 Wowza 上的流进行密码保护?