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

Function cycle_abs

test/timer_accuracy.cpp:6–14  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4using namespace co_context;
5
6task<> cycle_abs(int sec) {
7 auto next = std::chrono::steady_clock::now();
8 while (true) {
9 next = next + std::chrono::seconds{sec};
10 co_await timeout_at(next);
11 auto late = std::chrono::steady_clock::now() - next;
12 printf("late = %ld ns\n", late.count());
13 }
14}
15
16int main() {
17 io_context ctx;

Callers 1

mainFunction · 0.70

Calls 1

timeout_atFunction · 0.85

Tested by

no test coverage detected