作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在我的代码中,我打开了一个用于io服务的boost线程,并希望在while循环结束后关闭该线程。
目前,应用程序在 Debug模式下崩溃,并且我收到此错误消息。
Microsoft C++ exception
boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::system::system_error> > at memory location 0x000000000AA2F7D0.
Microsoft C++ exception:
boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::system::system_error> > at memory location 0x000000000AA2F7D0.
template<class F>
struct Cleaner {
Cleaner(F in) : f(in) {}
~Cleaner() { f(); }
F f;
};
template<class F>
Cleaner<F> makeCleaner(F f) {
return Cleaner<F>(f);
}
int main()
{
boost::asio::io_service io_service;
server server1(io_service, 1980);
boost::thread t(boost::bind(&io_service::run, &io_service));
while( loop )
{
}
auto raii = makeCleaner([&]() { io_service.stop(); }); // trying to close the boost thread
}
最佳答案
根据评论,仅调用io_service.stop()
是不够的。运行该服务的线程必须为 joined
才能正常退出。
关于c++ - 如何正确关闭助推器线程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62752051/
我正在使用 yii booster bootstrap,但 datepicker 不工作。我还发现 bootstrap-datepicker.js 没有在正确的路径中注册。 这是我得到的错误: htt
我运行了一个 xgboost 回归预测(也尝试用 xgb.Booster.complete 完成它)。尝试获取 xgb.importance 时,我收到错误信息 Error in xgboost::x
我是一名优秀的程序员,十分优秀!