Boost logo

Boost Users :

Subject: [Boost-users] [thread] terminating a thread when a program exits
From: Sean Farrow (sean.farrow_at_[hidden])
Date: 2011-07-09 22:15:48

I've got a situation whereby, I've got a number of boost::thread objects being created by classes in my program and run for the duration of the program. What I need to do is when the exit menu item is activated, close down all threads.
I was going to use a condition, and have the threads continue until the condition is signalled, and then use notify_all when the exit menu item is activated.
Given that I want this condition to be multi-read/exclusive write, what mutex is the best option?
Also will I need to use a mutex in the threads I need to terminate.
I see the code of the threads being something like:
While (Terminate !=false)
//perform actions.
Normally in this situation I'd use a windows event and the WaitForSingle/multipleObject functions, but as this has to be cross platform I carn't do this.
Any help with this appreciated.

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at