Is it safe to use std::conditional_variable::notify_one in signal handler. Example:
enum State {}; State state;
// worker thread
std::tread th = std::thread([]()
{
std::unique_lock lc(mutex);
cv.wait(lc, []() { return state; });
});
//signal handler
handler(int sig)
{
if (sig == SOME_SIG)
{
std::unique_lock lc(mutex);
state = Do;
cv.notify_one();
}
}
Aucun commentaire:
Enregistrer un commentaire