]> granicus.if.org Git - llvm/commitdiff
[Support] Fix locking of shared variable in threadpool
authorJan Korous <jkorous@apple.com>
Mon, 27 Nov 2017 13:42:03 +0000 (13:42 +0000)
committerJan Korous <jkorous@apple.com>
Mon, 27 Nov 2017 13:42:03 +0000 (13:42 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@319027 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Support/ThreadPool.cpp

index f1b5bdf40c32b4eea6a8a9bd80d0a4e30fe82e34..d0212ca13467bbd1808616ce0f65ff9176f99ea1 100644 (file)
@@ -47,8 +47,8 @@ ThreadPool::ThreadPool(unsigned ThreadCount)
           // in order for wait() to properly detect that even if the queue is
           // empty, there is still a task in flight.
           {
-            ++ActiveThreads;
             std::unique_lock<std::mutex> LockGuard(CompletionLock);
+            ++ActiveThreads;
           }
           Task = std::move(Tasks.front());
           Tasks.pop();