EventCountTest cleanups
authorSoren Lassen <soren@fb.com>
Sun, 24 Aug 2014 05:27:12 +0000 (22:27 -0700)
committerSara Golemon <sgolemon@fb.com>
Tue, 9 Sep 2014 21:22:23 +0000 (14:22 -0700)
Summary: based on code review feedback in D1516171

Test Plan: ran the test

Reviewed By: philipp@fb.com

Subscribers: njormrod

FB internal diff: D1516187

folly/experimental/test/EventCountTest.cpp

index 1c65f5fc97b2375ec909a5d6b966186187d8d7d3..cd30724297ea1d460e466049a5e7e9a109383c34 100644 (file)
 #include <folly/experimental/EventCount.h>
 
 #include <algorithm>
+#include <atomic>
 #include <random>
+#include <thread>
+#include <vector>
 #include <glog/logging.h>
 #include <gtest/gtest.h>
 
 #include <folly/Random.h>
-#include <folly/Benchmark.h>
 
 using namespace folly;
 
@@ -47,15 +49,12 @@ class Semaphore {
 
  private:
   bool tryDown() {
-    for (;;) {
-      int v = value_;
-      if (v == 0) {
-        return false;
-      }
+    for (int v = value_; v != 0;) {
       if (value_.compare_exchange_weak(v, v-1)) {
         return true;
       }
     }
+    return false;
   }
 
   std::atomic<int> value_;
@@ -124,14 +123,3 @@ TEST(EventCount, Simple) {
 
   EXPECT_EQ(0, sem.value());
 }
-
-int main(int argc, char *argv[]) {
-  testing::InitGoogleTest(&argc, argv);
-  gflags::ParseCommandLineFlags(&argc, &argv, true);
-  auto ret = RUN_ALL_TESTS();
-  if (!ret) {
-    folly::runBenchmarksOnFlag();
-  }
-  return ret;
-}
-