I have a method which is fired once every 30 seconds aprox. that I need to have in a thread.
I have a method that I can call from outside the class. Something like callThreadedMethod() which creates the thread which itself calls the final threadedMethod.
These are methods of MyClass
void callThreadedMethod(){
mThread = boost::shared_ptr<boost::thread>(new boost::thread(&MyClass::threadedMethod, this));
}
void threadedMethod(){
//more code NOT inside a while loop
}
So do I have to detach mThread every time the method is called?
Is it enough to call join() in the MyClass destructor?
Does the thread destroys itself when threadedMethod finishes?