20 #include <condition_variable> 24 using namespace folly;
34 std::condition_variable cv;
37 int numTotal = iters * numThreads;
39 std::vector<std::thread>
threads;
40 for (
int i = 0;
i < numThreads;
i++) {
41 threads.push_back(std::thread([&]()
mutable {
43 bool notifyAll =
false;
45 std::lock_guard<std::mutex> lk(m);
46 if (++numRunning == numThreads) {
55 std::unique_lock<std::mutex> lk(m);
56 cv.wait(lk, [&]() {
return numRunning == numThreads; });
59 for (
auto j = 0; j < iters; j++) {
61 if (++numProcessed == numTotal) {
73 for (
auto&
t : threads) {
86 gflags::ParseCommandLineFlags(&argc, &
argv,
true);
static size_t constexpr kMaxRead
void runTest(int iters, int numThreads)
—— Concurrent Priority Queue Implementation ——
std::vector< std::thread::id > threads
bool runInEventBaseThread(void(*fn)(T *), T *arg)
static map< string, int > m
#define BENCHMARK_PARAM(name, param)
void setMaxReadAtOnce(uint32_t maxAtOnce)
int main(int argc, char *argv[])