28 #include <gtest/gtest.h>
42 std::thread
t1([&] () {
43 std::lock_guard<UncontendedMutex>
g(
m);
46 std::this_thread::sleep_for(std::chrono::milliseconds(200));
50 std::thread
t2([&] () {
51 std::this_thread::sleep_for(std::chrono::milliseconds(100));
52 std::lock_guard<UncontendedMutex>
g(
m);
56 std::thread
t3([&] () {
57 std::this_thread::sleep_for(std::chrono::milliseconds(100));
58 std::lock_guard<UncontendedMutex>
g(
m);
70 int num_of_iter = 1000;
71 int num_of_thread = 1000;
77 for (
int t = 0 ;
t < num_of_thread; ++
t) {
78 threads.emplace_back([&] () {
79 for (
int k = 0;
k < num_of_iter; ++
k) {
80 std::lock_guard<UncontendedMutex>
g(
m);
86 for (
auto&
t : threads) {
89 EXPECT_EQ(
data, num_of_iter * num_of_thread);