MCPcopy Create free account
hub / github.com/alibaba/async_simple / TEST_F

Function TEST_F

async_simple/coro/test/SpinLockTest.cpp:35–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33};
34
35TEST_F(SpinLockTest, testLockImmediately) {
36 std::atomic<int> latch(5);
37 SpinLock spin;
38 auto data = 0;
39 auto addOne = [&]() -> Lazy<> {
40 auto scopeLock = co_await spin.coScopedLock();
41 data++;
42 latch--;
43 co_return;
44 };
45 addOne().via(&_executor).start([](Try<void> var) {});
46 addOne().via(&_executor).start([](Try<void> var) {});
47 addOne().via(&_executor).start([](Try<void> var) {});
48 addOne().via(&_executor).start([](Try<void> var) {});
49 addOne().via(&_executor).start([](Try<void> var) {});
50 while (latch) {
51 }
52 EXPECT_EQ(5, data);
53}
54
55TEST_F(SpinLockTest, testLockYield) {
56 std::atomic<int> latch(5);

Callers

nothing calls this directly

Calls 15

threadClass · 0.85
createFunction · 0.85
viaMethod · 0.80
emitsMethod · 0.80
get_futureMethod · 0.80
coScopedLockMethod · 0.45
startMethod · 0.45
coLockMethod · 0.45
unlockMethod · 0.45
lockMethod · 0.45
joinMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected