19 #include <condition_variable> 23 using namespace folly;
25 template <
typename Tag1,
typename Tag2>
34 std::condition_variable cv, cvw;
38 std::vector<std::thread>
threads;
39 for (
int i = 0;
i < numThreads;
i++) {
40 threads.push_back(std::thread([&]()
mutable {
46 std::lock_guard<std::mutex> lk(m);
47 if (++numRunning == numThreads) {
58 std::unique_lock<std::mutex> lk(mw);
59 cvw.wait(lk, [&]() {
return !running; });
66 std::unique_lock<std::mutex> lk(m);
67 cv.wait(lk, [&]() {
return numRunning == numThreads; });
76 for (
int i = 0;
i < iters;
i++) {
84 std::lock_guard<std::mutex> lk(mw);
90 for (
auto&
t : threads) {
96 runTestTag<void, void>(iters, numThreads);
100 runTestTag<void, int>(iters, numThreads);
120 gflags::ParseCommandLineFlags(&argc, &argv,
true);
int main(int argc, char *argv[])
void reset(T *newPtr=nullptr)
—— Concurrent Priority Queue Implementation ——
void runTestSameTag(int iters, int numThreads)
std::vector< std::thread::id > threads
void runTestTag(int iters, int numThreads)
void runTestDiffTag(int iters, int numThreads)
static map< string, int > m
#define BENCHMARK_PARAM(name, param)