I have the following situation
std::mutex m;
void t() {
//lock the mutex m here
}
main() {
//create thread t here
//lock the mutex m here
}
I would like the thread t() to acquire the mutex before main(), how can I obtain this behaviour using the threading functions provided by C++0x? Putting simply an std::lock_guard inside main() and t() would not work because it can take a bit before the thread is spawned, an so the mutex can be locked by main().
Aucun commentaire:
Enregistrer un commentaire