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

Method occupy_sema

example/sem.cpp:44–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42 task<void> initial_delay() const { co_await timeout(delay * time_tick); }
43
44 task<void> occupy_sema() {
45 wait_on_sema = static_cast<unsigned>(
46 std::chrono::duration_cast<std::chrono::milliseconds>(
47 std::chrono::high_resolution_clock::now() - started_at
48 - delay * time_tick
49 )
50 .count()
51 / time_tick.count()
52 );
53 co_await timeout(occupy * time_tick);
54 }
55
56 task<void> visualize(unsigned id, unsigned x_scale = 2) const {
57 auto cout_n = [=](auto str, unsigned n) {

Callers 1

workerThreadFunction · 0.45

Calls 1

timeoutFunction · 0.85

Tested by

no test coverage detected