19 #include <condition_variable> 23 using namespace folly;
45 std::vector<SimpleThreadCachedInt> stci(numThreads);
48 std::condition_variable cv, cvw;
52 std::vector<std::thread>
threads;
53 for (
int i = 0;
i < numThreads;
i++) {
54 threads.push_back(std::thread([
i,
62 &numRunning]()
mutable {
69 std::lock_guard<std::mutex> lk(m);
70 if (++numRunning == numThreads) {
81 std::unique_lock<std::mutex> lk(mw);
82 cvw.wait(lk, [&]() {
return !running; });
89 std::unique_lock<std::mutex> lk(m);
90 cv.wait(lk, [&]() {
return numRunning == numThreads; });
96 for (
int i = 0;
i < iters;
i++) {
97 stci[
i % numThreads].access();
103 std::lock_guard<std::mutex> lk(mw);
109 for (
auto&
t : threads) {
124 gflags::ParseCommandLineFlags(&argc, &argv,
true);
Accessor accessAllThreads() const
—— Concurrent Priority Queue Implementation ——
std::vector< std::thread::id > threads
static map< string, int > m
void runTest(int iters, int numThreads)
#define BENCHMARK_PARAM(name, param)
int main(int argc, char *argv[])