From: Soren Lassen Date: Sun, 24 Aug 2014 05:27:12 +0000 (-0700) Subject: EventCountTest cleanups X-Git-Tag: v0.22.0~383 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=9b4749fd47c605c27b6973f317d7c4f3a0e101e9;p=folly.git 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 --- 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; -} -