Boost-asio deadline_timer运行时错误
Boost-asio deadline_timer runtime error
所以,我正在遵循教程,试图设置一个基本的计时器…
void print(const boost::system::error_code &e)
{
std::cout <<"hello world"<< std::endl;
}
int main()
{
boost::asio::io_service io;
boost::asio::deadline_timer timer(io, boost::posix_time::seconds(5));
timer.async_wait(print);
io.run();
}
构建良好,但在运行时;
terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::system::system_error> >'
what(): thread: The attempted operation is not supported for the type of object referenced
Win7, GCC, code::blocks
编辑;在另一台机器上尝试了相同的设置-结果相同。
编辑;我应该从boost 1_47切换到最新版本吗?
您的代码使用MinGw 4.8和boost 1.55为我工作。但是,尝试将对timer.async_wait
的调用更改为:
#include <boost/bind.hpp>
timer.async_wait(boost::bind(&print, boost::asio::placeholders::error));
我切换了boost 1.56,它工作了
相关文章:
- 删除指向指针的指针是运行时错误吗
- c++中的指针和运行时错误
- 无法理解此 return 语句的功能,没有它就会发生运行时错误
- 在同一模拟中使用静脉和静脉_ inet内容时出现运行时错误
- 对单向链表进行排序时出现运行时错误
- 为什么此代码存在运行时错误?
- 你能解释一下什么运行时错误是如何解决它的吗?
- 为什么会出现 gettnig 运行时错误:加载类型为"_Bit_type"(stl_bvector.h) 的空指针?
- 为什么程序在 c++ 中迭代 emtpy 向量时会抛出运行时错误
- 运行时错误:引用绑定到类型为"int"的空指针
- 为什么当 vector 为空时会显示运行时错误?
- C++运行时错误与快速排序算法抛出堆栈转储错误
- 运行时错误:矢量下标超出范围:正在检查空集
- 分配给gslice_array会导致运行时错误
- cout 新创建的对象引发运行时错误
- C++在使用std::multimap时出现运行时错误的几率很小
- 运行时错误:引用绑定到类型"int"的未对齐地址0xbebebebebebebec6,这需要 4 个字节对齐 (stl_vector.h)
- 试图找出为什么我会收到运行时错误?
- 迭代二维矢量时发生运行时错误
- 调用 java 的回调() 时应用程序崩溃.由于 detatchThread 而获得运行时错误