提升 asio 绑定读取处理程序
Boost asio bind read handler
我正在尝试绑定读取处理程序,而提升 asio 让我发疯。
我有以下课程
class namenode_registration:
public boost::enable_shared_from_this<namenode_registration>,
private boost::noncopyable {
private:
[...]
public:
namenode_registration(....);
[...]
void handle_request_sent(const boost::system::error_code& e);
void handle_read_reply_type(boost::asio::mutable_buffers_1& buffer,
const boost::system::error_code& e, std::size_t bytes_transferred);
};
通过以下实现:
void namenode_registration::handle_request_sent(
const boost::system::error_code& e) {
if (!e) {
boost::asio::async_read(socket_,
boost::asio::buffer(buffer_data_, namenode::reply::type_size),
boost::bind(&namenode_registration::handle_read_reply_type,
shared_from_this(), boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred));
}
}
而且我真的不明白为什么它不编译:
In file included from /usr/include/boost/bind.hpp:22:0,
from /home/.../datanode/namenode_registration.cpp:9:
/usr/include/boost/bind/bind.hpp:
In instantiation of ‘boost::_bi::result_traits<boost::_bi::unspecified,
void (datanode::namenode_registration::*)(boost::asio::mutable_buffers_1&,
const boost::system::error_code&, long unsigned int)>’:
/usr/include/boost/bind/bind_template.hpp:15:48:
instantiated from ‘boost::_bi::bind_t<boost::_bi::unspecified, void (datanode::namenode_registration::*
(boost::asio::mutable_buffers_1&, const boost::system::error_code&, long unsigned int),
boost::_bi::list3<boost::_bi::value<boost::shared_ptr<datanode::namenode_registration> >,
boost::arg<1> (*)(), boost::arg<2> (*)()> >’
/home/.../datanode/namenode_registration.cpp:50:51:
instantiated from here
/usr/include/boost/bind/bind.hpp:69:37:
erreur: ‘void (datanode::namenode_registration::*)(boost::asio::mutable_buffers_1&,
const boost::system::error_code&, long unsigned int)’ is not a class, struct, or union type
您尚未为此函数绑定足够的参数:
void handle_read_reply_type(boost::asio::mutable_buffers_1& buffer,
const boost::system::error_code& e, std::size_t bytes_transferred);
您缺少缓冲区参数:
boost::bind(&namenode_registration::handle_read_reply_type,
shared_from_this(), boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred));
相关文章:
- 获取日期异步信号安全吗?如果在信号处理程序中使用,它会导致死锁吗
- 如何在信号处理程序和普通函数中对全局变量进行互斥读写操作
- 为什么我的 IExtractIcon 处理程序没有被调用?
- 在遍历处理程序的向量时注册和注销处理程序
- 有可能在信号处理程序中设置promise吗
- 在信号处理程序中捕获C++未处理的异常并恢复应用程序
- 通过安装信号处理程序关闭多线程应用程序
- QDateTime::toString() 在退出处理程序中使用时失败
- 如何在 WindowProc 处理程序中区分箭头键和数字键盘?
- async_write完成处理程序最早何时完成?
- C++事件系统 - 多态事件和事件处理程序
- 具有shared_ptr的处理程序中的分段错误
- 为什么我的信号处理程序只执行一次?
- GTK C++:找不到信号处理程序 您是否使用 -rdynamic 进行了编译?
- 如何使用从处理程序调度的最终回调将响应异步返回给调用方on_read?
- C++ 在信号处理程序后继续执行
- wxWidgets 拖放文件事件处理程序初始化问题(无效static_cast)
- 某些 boost::asio 异步函数是否将处理程序连接到操作,以便处理程序被触发一次?
- 没有信号处理程序的POSIX定时器的目的是什么?
- 处理程序的模块列表中有一个错误的模块"WebSocketModule"