28 #include <gtest/gtest.h>
40 std::thread
t1([&] () {
41 std::lock_guard<UncontendedMutex>
g(
m);
44 std::this_thread::sleep_for(std::chrono::milliseconds(200));
48 std::thread
t2([&] () {
49 std::this_thread::sleep_for(std::chrono::milliseconds(100));
50 std::lock_guard<UncontendedMutex>
g(
m);
54 std::thread
t3([&] () {
55 std::this_thread::sleep_for(std::chrono::milliseconds(100));
56 std::lock_guard<UncontendedMutex>
g(
m);
68 int num_of_iter = 1000;
69 int num_of_thread = 1000;
75 for (
int t = 0 ;
t < num_of_thread; ++
t) {
76 threads.emplace_back([&] () {
77 for (
int k = 0;
k < num_of_iter; ++
k) {
78 std::lock_guard<UncontendedMutex>
g(
m);
84 for (
auto&
t : threads) {
87 EXPECT_EQ(
data, num_of_iter * num_of_thread);