
14 Feb
2006
14 Feb
'06
10:41 p.m.
Steven Wooding wrote:
Hi,
I've had a good search on the mailing list and while some posts have got close to my problem and given me a few glues, my code does't quite work the way I want it to.
My goal is to have a (non-static) class member function run in a child thread + passing a parameter to it. The code I've got at the moment goes something like this:
void MyClass::spawn_threads() { for ( int ii = 0; ii < num_threads; ++ii) { threadGroup.create_thread( boost::bind( ChildThreadFunc, _1, ii));
You need threadGroup.create_thread( boost::bind( &MyClass::ChildThreadFunc, this, ii ) ); here.
} }
void MyClass::ChildThreadFunc( int &threadNumber) { // Does some work }