From 9b4749fd47c605c27b6973f317d7c4f3a0e101e9 Mon Sep 17 00:00:00 2001 From: Soren Lassen Date: Sat, 23 Aug 2014 22:27:12 -0700 Subject: [PATCH] EventCountTest cleanups 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 | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/folly/experimental/test/EventCountTest.cpp b/folly/experimental/test/EventCountTest.cpp index 1c65f5fc..cd307242 100644 --- a/folly/experimental/test/EventCountTest.cpp +++ b/folly/experimental/test/EventCountTest.cpp @@ -17,12 +17,14 @@ #include #include +#include #include +#include +#include #include #include #include -#include 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 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; -} - -- 2.34.1