Fix copyright lines
[folly.git] / folly / futures / test / BarrierTest.cpp
index 47a3e3d9e0901c3b23bf6c4306a9816defcfc450..3e8021710a0df38f96ac4e1c0a3ef3ad8723e0f9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2016 Facebook, Inc.
+ * Copyright 2015-present Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,8 +21,9 @@
 #include <mutex>
 
 #include <folly/Random.h>
+#include <folly/portability/GTest.h>
+
 #include <glog/logging.h>
-#include <gtest/gtest.h>
 
 namespace folly { namespace futures { namespace test {
 
@@ -111,7 +112,7 @@ TEST(BarrierTest, Random) {
   //
   // At the end, we verify that exactly one future returning true was seen
   // for each iteration.
-  constexpr uint32_t numIterations = 1;
+  static constexpr uint32_t numIterations = 1;
   auto numThreads = folly::Random::rand32(30, 91);
 
   struct ThreadInfo {
@@ -136,23 +137,21 @@ TEST(BarrierTest, Random) {
 
   for (auto& tinfo : threads) {
     auto pinfo = &tinfo;
-    tinfo.thread = std::thread(
-        [numIterations, pinfo, &barrier] () {
-          std::vector<folly::Future<bool>> futures;
-          futures.reserve(pinfo->numFutures);
-          for (uint32_t i = 0; i < numIterations; ++i, ++pinfo->iteration) {
-            futures.clear();
-            for (uint32_t j = 0; j < pinfo->numFutures; ++j) {
-              futures.push_back(barrier.wait());
-              auto nanos = folly::Random::rand32(10 * 1000 * 1000);
-              /* sleep override */
-              std::this_thread::sleep_for(std::chrono::nanoseconds(nanos));
-            }
-            auto results = folly::collect(futures).get();
-            pinfo->trueSeen[i] =
-              std::count(results.begin(), results.end(), true);
-          }
-        });
+    tinfo.thread = std::thread([pinfo, &barrier] {
+      std::vector<folly::Future<bool>> futures;
+      futures.reserve(pinfo->numFutures);
+      for (uint32_t i = 0; i < numIterations; ++i, ++pinfo->iteration) {
+        futures.clear();
+        for (uint32_t j = 0; j < pinfo->numFutures; ++j) {
+          futures.push_back(barrier.wait());
+          auto nanos = folly::Random::rand32(10 * 1000 * 1000);
+          /* sleep override */
+          std::this_thread::sleep_for(std::chrono::nanoseconds(nanos));
+        }
+        auto results = folly::collect(futures).get();
+        pinfo->trueSeen[i] = std::count(results.begin(), results.end(), true);
+      }
+    });
   }
 
   for (auto& tinfo : threads) {
@@ -169,4 +168,6 @@ TEST(BarrierTest, Random) {
   }
 }
 
-}}}  // namespaces
+} // namespace test
+} // namespace futures
+} // namespace folly