[thread] Undefined behaviour of mutex?

While making use of mutex objects, namely in the wait function I found out that I may not destroy a mutex while a thread is waiting for it to become signalled. On windows this results in undefined behaviour and with pthreads this raises an assertion (in debug build). I am aware that this could be solved by using an additional "aborted" variable that could be tested in the while loop of the cond.wait(lk) call, but I cannot see a straightforward way how to test abortion when waiting in a try to simply lock such a mutex. So I raise the question if it would be desirable to have the mutex "throw exceptions to all threads" that are waiting for it when it is to be destroyed? Does anyone have another idea of how to deal with this situation properly? regards, Roland
participants (1)
-
Roland Schwarz