#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;
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_;
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;
-}
-