Boost logo

Boost Users :

From: Germain BARRET (germain.barret_at_[hidden])
Date: 2008-07-09 11:40:40


Is their any probleme with boost::thread and inherited functions ?

Here is an example of what doesn't work to me :

Class A {
public:
makeWork() { runThat(); } ;

protected:
virtual runThat(void);
} //A

Class B : public A {
public :
init() { boost::thread(makeWork); }; //v1
init() { boost::thread(boost::bind(B::makeWork)); }; //v2

private :
runThat(void) { printf("foo"); };
}

No way, once makeWork never run, or with boost::bind, boost::ref,
boost::function... I have still errors (do I need to post the errors... ?)

That why befor posting any error log, I ask if there are known problems with
inheritage and boost::thread ?

Of course I know how to use boost::thread and boost::bind, for example if I
had this to B, it works

Class B : public A {
...
public :
init2() { boost::thread(foo); };

private :
foo(void) { printf("foo"); };
...
}

So what ???

In fact, in the real case, B inherit from another class one of my own
invention : Singleton<CLASS> no need to explain what it does... maybe the
"1 object only" is a problem for boost ?

PS : the docs have very few complete examples, do you preview to extend it ?
(usage of thread, bind, function, ref in the same example please) monolithic
examples are OK to understand the principle, but not to understand complex
usages...



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net