且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

升压主题:删除功能的错误使用

更新时间:2023-01-23 15:27:00

线程构造函数会将它的参数,而的消息类型是不可拷贝。传递给需要使用的目标函数的引用的boost :: REF(MSG)

The thread constructor copies its arguments, and the message type is not copyable. To pass a reference to the target function you need to use boost::ref(msg)

另外请注意,使用绑定线程是多余的:

Also note that using bind with thread is unnecessary:

boost::thread thrd(&handover_request_handler, boost::ref(msg), boost::ref(ec));

线程构造实现了相同的语义绑定,因此,使用绑定只是增加了不必要的额外拷贝。

The thread constructor implements the same semantics as bind, so using bind just adds unnecessary additional copying.