C ++ //将Boost ::数组传递给Boost :: thread

时间:2016-03-03 10:14:41

标签: c++ multithreading boost

我想传递一个" boost :: array" to" booth :: thread"工作

typedef unsigned char BYTE;
boost::array<BYTE,256> readBuffer;
thread gojob(&thread_job, readBuffer.data() );

如何通过?

void serial::thread_job(BYTE *received) {

}

我写了这个..但是编译只给了我奇怪的信息.. 我无法理解他在说什么......

include/boost/bind/mem_fn.hpp:333:36: error: cannot apply member pointer ‘((const boost::_mfi::dm<void(unsigned char*), serial>*)this)->boost::_mfi::dm<void(unsigned char*), serial>::f_’ to ‘* boost::get_pointer<unsigned char>(((unsigned char*)u))’, which is of non-class type ‘unsigned char’

1 个答案:

答案 0 :(得分:0)

传递缓冲区然后处理数据(),您可以执行以下操作:

thread gojob(boost::bind(&serial::thread_job,this, boost::ref(readBuffer))