Make ThreadSystem work on windows

This commit is contained in:
Sebastian Messmer 2018-05-20 00:25:36 -07:00
parent 736052b0ee
commit d0fb8b8412

View File

@ -12,9 +12,13 @@ namespace cpputils {
}
ThreadSystem::ThreadSystem(): _runningThreads(), _mutex() {
#if !defined(_MSC_VER)
//Stopping the thread before fork() (and then also restarting it in the parent thread after fork()) is important,
//because as a running thread it might hold locks or condition variables that won't play well when forked.
pthread_atfork(&ThreadSystem::_onBeforeFork, &ThreadSystem::_onAfterFork, &ThreadSystem::_onAfterFork);
#else
// not needed on windows because we don't fork
#endif
}
ThreadSystem::Handle ThreadSystem::start(function<bool()> loopIteration) {