feat(util/thread): handle thread creation/join failure on Windows

This commit is contained in:
Leonardo de Moura 2016-12-05 09:53:41 -08:00
parent 612cde33b6
commit c77a987b4d

View file

@ -45,10 +45,15 @@ struct lthread::imp {
m_proc(p) {
m_thread = CreateThread(nullptr, m_thread_stack_size,
_main, &m_proc, 0, nullptr);
if (m_thread == NULL) {
throw exception("failed to create thread");
}
}
void join() {
WaitForSingleObject(m_thread, INFINITE);
if (WaitForSingleObject(m_thread, INFINITE) == WAIT_FAILED) {
throw exception("failed to join thread");
}
}
};
#else