MCPcopy Create free account
hub / github.com/apache/trafficserver / run

Function run

tools/benchmark/benchmark_SharedMutex.cc:50–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48Conf conf;
49template <typename T, typename S>
50int
51run(T &mutex)
52{
53 std::thread list[conf.nthreads];
54 int counter = 0;
55
56 for (int i = 0; i < conf.nthreads; i++) {
57 new (&list[i]) std::thread{[&counter](T &mutex) {
58 int c = 0;
59 for (int j = 0; j < conf.nloop; ++j) {
60 // reader
61 for (int i = 0; i < conf.nread; ++i) {
62 S lock(mutex);
63 // Do not optimize
64 c = counter;
65 }
66
67 // writer
68 for (int i = 0; i < conf.nwrite; ++i) {
69 std::lock_guard lock(mutex);
70 // Do not optimize
71 ++c;
72 counter = c;
73 }
74 }
75 },
76 std::ref(mutex)};
77 }
78
79 for (int i = 0; i < conf.nthreads; i++) {
80 list[i].join();
81 }
82
83 return counter;
84}
85
86} // namespace
87

Callers

nothing calls this directly

Calls 1

joinMethod · 0.80

Tested by

no test coverage detected