For some reason the call signal.notify_one() blocks the current thread and doesn't return. I have never heard about this behavior and I don't know how to resolve it.
{
std::lock_guard<std::mutex> lock(_mutex);
_exit = true; // _exit is a std::atomic<bool>
}
std::cout << "before" << std::endl;
_signal.notify_one();
std::cout << "after" << std::endl;
_thread.join();
I'm using Microsoft Visual C++ 2015 and the code above is called during destruction.
I hope you can point me in the right direction, thank you much for your help!
_exit
to bestd::atomic
given that it is protected by_mutex
. - GigaRohannotify_one
may awaken a thread that had called_signal.wait()
, which is where your code may be. Consider adding breakpoints after your_signal.wait()
to see if that's where your code returns to - Tas