MCPcopy Create free account
hub / github.com/Codesire-Deng/co_context / g

Function g

example/stop_token.cpp:5–22  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3using namespace std::chrono_literals;
4
5task<> g(stop_token token) {
6 printf("g() is running...\n");
7
8 stop_callback guard{token, [] {
9 printf("Callback is triggerd\n");
10 }};
11
12 co_await timeout(1s);
13
14 // It is your responsibility to check
15 // whether the task has been cancelled.
16 if (token.stop_requested()) {
17 printf("g() exits early\n");
18 co_return;
19 }
20
21 printf("g() finished\n");
22}
23
24task<> f() {
25 // The same as std::stop_source.

Callers 1

fFunction · 0.70

Calls 2

timeoutFunction · 0.85
stop_requestedMethod · 0.45

Tested by

no test coverage detected