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

Function TEST_F

async_simple/uthread/test/UthreadTest.cpp:79–99  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77};
78
79TEST_F(UthreadTest, testSimple) {
80 auto show = [&](const std::string& message) mutable {
81 std::cout << message << "\n";
82 };
83 std::atomic<bool> done(false);
84 _executor.schedule([&done, ex = &_executor, &show]() {
85 Uthread ut(Attribute{ex}, [&show]() { show("task 1"); });
86 ut.join([ex, &done, &show]() {
87 show("task 1 done");
88 ex->schedule([ex, &done, &show]() {
89 Uthread ut(Attribute{ex}, [&show]() { show("task 2"); });
90 ut.join([&done, &show]() {
91 show("task 2 done");
92 done = true;
93 });
94 });
95 });
96 });
97 while (!done) {
98 }
99}
100
101TEST_F(UthreadTest, testSwitch) {
102 Executor* ex = &_executor;

Callers

nothing calls this directly

Calls 15

delayedTaskFunction · 0.85
awaitFunction · 0.85
asyncFunction · 0.85
UthreadClass · 0.85
lazySumFunction · 0.85
viaMethod · 0.80
getFutureMethod · 0.80
setValueMethod · 0.80
thenValueMethod · 0.80
awaitMethod · 0.80
currentCountMethod · 0.80
bindFunction · 0.50

Tested by

no test coverage detected