|
Boost Users : |
From: Joshua ChaitinPollak (jpollak_at_[hidden])
Date: 2007-02-06 12:27:29
Hello,
I have a question about Boost.Thread. I am trying to create a class
which upon instantiation creates a thread based upon itself, and then
on destruction, stops the thread and cleans up after itself. A simple
example is below. Is this possible, and if not, what alternatives do
I have?
The reason for this is to create a single external API (actually
defined in a base class), and still have a background thread (hidden
from the API) which can share that object's internal member variables.
I'm looking to do something like this:
class my_handler {
public:
boost::thread* background_thread;
my_hander() : background_thread(NULL) {
background_thread(*this);
}
~my_hander() {
if (background_thread != NULL) {
running = false;
background_thread.join();
}
operator()() {
while(running) {
// do something
}
}
};
-Thanks,
Josh
-- Joshua ChaitinPollak Software Engineer Kiva Systems
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