MCPcopy Create free account
hub / github.com/bloomberg/quantum / TEST

Function TEST

tests/quantum_locks_tests.cpp:87–110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

85}
86
87TEST(Locks, Spinlock)
88{
89 val = 0;
90 SpinLock spin;
91 std::thread t1([&]() mutable {
92 int num = spins;
93 while (num-- > 0) {
94 SpinLock::Guard guard(spin);
95 //std::this_thread::yield();
96 ++val;
97 }
98 });
99 std::thread t2([&]() mutable {
100 int num = spins;
101 while (num-- > 0) {
102 SpinLock::Guard guard(spin);
103 //std::this_thread::yield();
104 --val;
105 }
106 });
107 t1.join();
108 t2.join();
109 EXPECT_EQ(0, val);
110}
111
112TEST(Locks, Spinlock_Guards)
113{

Callers

nothing calls this directly

Calls 15

spinlockSettingsFunction · 0.85
yieldFunction · 0.85
joinMethod · 0.80
notifyAllMethod · 0.80
yieldMethod · 0.80
ownsLockMethod · 0.45
isLockedMethod · 0.45
lockMethod · 0.45
unlockMethod · 0.45
numReadersMethod · 0.45
lockReadMethod · 0.45
unlockReadMethod · 0.45

Tested by

no test coverage detected