
"Vladimir Pozdyaev"
Hello.Is it feasible to make CVs' destructors thread-safe? Consider the code below. It causes a failed assertion in basic_condition_variable::dispose_entry(...) when cv's destructor kicks in while notify_all() is still cleaning up. The problem is easily resolved by adding another mutex, but it would just look nicer if we could rely on cv's own features for that.Another alternative would be to make wait() return only after notify_xxx() has really finished its job. (Yes, I guess this code is not exactly a Good Practice :) , but it's not exactly logically inconsistent either. Or is it?)[Boost 1.35.0, MSVC2008, Win32 Debug configurationActually, it's not easy to make this particular code fail; adding a short sleep() in the beginning of dispose_entry(...) helps. This problem managed to appear quite systematically in a more complex program though.
First off, Boost 1.35.0 condition variables are broken on Windows. Please update from subversion trunk or release branch. However, it is never safe to destroy any object whilst another thread might still be in a member function. If you use your mutex to protect the notify too, everything will be fine. Anthony -- Anthony Williams | Just Software Solutions Ltd Custom Software Development | http://www.justsoftwaresolutions.co.uk Registered in England, Company Number 5478976. Registered Office: 15 Carrallack Mews, St Just, Cornwall, TR19 7UL