boost::bind II
来源:互联网 发布:淘宝人生txt下载 编辑:程序博客网 时间:2024/06/06 16:27
//1 Use boost::bind not in a Class char buff[1024]; //buff must be global or static, or from a new() memory!void handle_write(boost::asio::serial_port &port,const boost::system::error_code &ec){ port.async_read_some(boost::asio::buffer(buff), boost::bind(handle_read,boost::ref(port), boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));}void handle_read(boost::asio::serial_port &port,const boost::system::error_code &ec,size_t byte_read) //not a fixed format{//See above: boost::bind()}char cCmd = 0x02;boost::asio::async_write( port, boost::asio::buffer(&cCmd,1), boost::bind(handle_write,boost::ref(port), boost::asio::placeholders::error) ); //2 Use boost::bind in a Class void SerialPort::handle_write(const boost::system::error_code &ec){ m_port.async_read_some(boost::asio::buffer(buff), boost::bind(&SerialPort::handle_read,this, //this, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));}void SerialPort::handle_read(const boost::system::error_code &ec,size_t byte_read) //This is a fixed format! must be so?{//See above: boost::bind()}char cCmd = 0x02;boost::asio::async_write( m_port, //a member in a class boost::asio::buffer(&cCmd,1), boost::bind(&SerialPort::handle_write,this, //this, boost::asio::placeholders::error) );
boost::thread 传递参数问题:void TcpTask(boost::asio::io_service &iostcp){ iostcp.run(); //循环分发回调函数}int main(){ boost::asio::io_service iostcp; boost::thread thread_tcp(boost::bind(&TcpTask, boost::ref(iostcp))); thread_tcp.join(); return 0;}
0 0
- boost::bind II
- boost.bind
- boost::bind
- boost::bind
- boost::bind
- Boost::bind
- Boost::bind
- bind -boost
- boost::bind()
- boost bind
- boost::bind
- boost::bind
- boost::bind
- boost bind
- boost::bind
- boost::bind()
- boost::bind
- boost::bind
- Linux环境下Tomcat的重启(markdown)
- xstream解析xml到实体类
- 微信多客服开发
- 关于eclipse安装PyDev后preference下始终没有Pydev选项的解决方案
- Win7+VMware Workstation环境下的CentOS-Linux网络连接设置
- boost::bind II
- C语言之冒泡法排序
- lenovo双屏显示不同内容配置
- handler消息机制了解
- 有关session的登录注销的一个小例子
- CCTYPE函数系列
- KVM源代码分析1:基本工作原理
- Redis Sharding方案
- Why does this code using `::boost::bind` get a compiler error?