10 Sep
2009
10 Sep
'09
9:34 p.m.
On Thu, Sep 10, 2009 at 10:20 PM, Boost lzw
Thanks. bind(&test_thread, s) works.
How can I bind one boost::thread to another boost::thread? Here is what I want to do: void work_thread() { cout << "done" << endl; }
void test_thread(boost::thread& t) { while (t.joinable()) { // do sth. this_thread::sleep(seconds(2)); } }
int main() { boost::thread work_thread(work_thread);
// this line does not compile boost::thread inquiry_thread(bind(&test_thread, work_thread ) );
Wrap it in a boost::ref wrapper: boost::thread inquiry_thread(bind(&test_thread, ref(work_thread) ) );
work_thread.join(); inquiry_thread.join(); return 0; }
Thanks in advance.
Robert
Stuart Dootson