
15 Feb
2006
15 Feb
'06
12:03 a.m.
Marc Mutz wrote:
On Tuesday 14 February 2006 22:34, Steven Wooding wrote:
void MyClass::spawn_threads() { for ( int ii = 0; ii < num_threads; ++ii) { threadGroup.create_thread( boost::bind( ChildThreadFunc, _1, ii)); } }
void MyClass::ChildThreadFunc( int &threadNumber) { // Does some work }
C++ question. Use &MyClass::ChildThreadFunction as bind's first argument. You will probably also run into trouble with passing the int by reference (why?).
Because MyClass::ChildThreadFunc is run in a different thread, in a separate timeline, and when it runs the variable ii may no longer exist (?). That's my guess, anyway.
Pass it by value.
That does seem more appropriate. Regards, João