
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
participants (1)
-
Joshua ChaitinPollak