From d0fb8b84129a2f48da2cd71c3fb71aef1d969a80 Mon Sep 17 00:00:00 2001 From: Sebastian Messmer Date: Sun, 20 May 2018 00:25:36 -0700 Subject: [PATCH] Make ThreadSystem work on windows --- src/cpp-utils/thread/ThreadSystem.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cpp-utils/thread/ThreadSystem.cpp b/src/cpp-utils/thread/ThreadSystem.cpp index 83827576..4451a668 100644 --- a/src/cpp-utils/thread/ThreadSystem.cpp +++ b/src/cpp-utils/thread/ThreadSystem.cpp @@ -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 loopIteration) {