我有一个带有对象指针的向量,我试图在一个新线程中启动对象的方法(方法有一个参数)。
这是我无法编译的代码:
class CanaSynchDynamic {
...
void start() (boost::barrier&);
...
};
主要是:
for(int i=0;i<pw;++i)
vS1.push_back(new CanaSynchDynamic());
do {
boost::barrier barrier(pw);
boost::thread_group threads;
for(int i=0;i<pw;++i)
vS1[i]->more_steps(start,s[z]);
for(int i=0;i<pw;++i)
threads.create_thread(boost::bind(&CanaSynchDynamic::start,boost::ref(*(vS1[i])),boost::ref(barrier)));
threads.join_all();
} while(something);
错误是:
/usr/include/boost/thread/detail/thread.hpp: In instantiation of 'void
boost::detail::thread_data<boost::reference_wrapper<T> >::run() [with F = CanaSynchDynamic]':
simulation_3.cpp:278:1: required from here
/usr/include/boost/thread/detail/thread.hpp:98:17: error: no match for call to '(CanaSynchDynamic) ()'
你有什么主意吗?