summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/unittests/clangd/ThreadingTests.cpp
diff options
context:
space:
mode:
authorIlya Biryukov <ibiryukov@google.com>2018-02-06 19:22:40 +0000
committerIlya Biryukov <ibiryukov@google.com>2018-02-06 19:22:40 +0000
commit3693f5941ab6ecefd173c94c6be2ae56a51acdf7 (patch)
tree3f143e0ce54f0bdf8dd0b53184fd28836ff28324 /clang-tools-extra/unittests/clangd/ThreadingTests.cpp
parent6ef990e9ce9ab7d3a2b055e53ff83236d01f43fa (diff)
downloadbcm5719-llvm-3693f5941ab6ecefd173c94c6be2ae56a51acdf7.tar.gz
bcm5719-llvm-3693f5941ab6ecefd173c94c6be2ae56a51acdf7.zip
Revert "[clangd] The new threading implementation" (r324356)
And the follow-up changes r324361 and r324363. These changes seem to break two buildbots: - http://lab.llvm.org:8011/builders/clang-atom-d525-fedora-rel/builds/14091 - http://lab.llvm.org:8011/builders/clang-x86_64-linux-selfhost-modules-2/builds/16001 We will need to investigate what went wrong and resubmit the changes afterwards. llvm-svn: 324386
Diffstat (limited to 'clang-tools-extra/unittests/clangd/ThreadingTests.cpp')
-rw-r--r--clang-tools-extra/unittests/clangd/ThreadingTests.cpp65
1 files changed, 0 insertions, 65 deletions
diff --git a/clang-tools-extra/unittests/clangd/ThreadingTests.cpp b/clang-tools-extra/unittests/clangd/ThreadingTests.cpp
deleted file mode 100644
index 84e6512fe43..00000000000
--- a/clang-tools-extra/unittests/clangd/ThreadingTests.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-//===-- ThreadingTests.cpp --------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "Threading.h"
-#include "gtest/gtest.h"
-#include <mutex>
-
-namespace clang {
-namespace clangd {
-class ThreadingTest : public ::testing::Test {};
-
-TEST_F(ThreadingTest, TaskRunner) {
- const int TasksCnt = 100;
- // This should be const, but MSVC does not allow to use const vars in lambdas
- // without capture. On the other hand, clang gives a warning that capture of
- // const var is not required.
- // Making it non-const makes both compilers happy.
- int IncrementsPerTask = 1000;
-
- std::mutex Mutex;
- int Counter(0); /* GUARDED_BY(Mutex) */
- {
- AsyncTaskRunner Tasks;
- auto scheduleIncrements = [&]() {
- for (int TaskI = 0; TaskI < TasksCnt; ++TaskI) {
- Tasks.runAsync([&Counter, &Mutex, IncrementsPerTask]() {
- for (int Increment = 0; Increment < IncrementsPerTask; ++Increment) {
- std::lock_guard<std::mutex> Lock(Mutex);
- ++Counter;
- }
- });
- }
- };
-
- {
- // Make sure runAsync is not running tasks synchronously on the same
- // thread by locking the Mutex used for increments.
- std::lock_guard<std::mutex> Lock(Mutex);
- scheduleIncrements();
- }
-
- Tasks.waitForAll();
- {
- std::lock_guard<std::mutex> Lock(Mutex);
- ASSERT_EQ(Counter, TasksCnt * IncrementsPerTask);
- }
-
- {
- std::lock_guard<std::mutex> Lock(Mutex);
- Counter = 0;
- scheduleIncrements();
- }
- }
- // Check that destructor has waited for tasks to finish.
- std::lock_guard<std::mutex> Lock(Mutex);
- ASSERT_EQ(Counter, TasksCnt * IncrementsPerTask);
-}
-} // namespace clangd
-} // namespace clang
OpenPOWER on IntegriCloud