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

Function workerThread

example/sem.cpp:82–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

80std::array<Guide, max_threads> guides;
81
82task<> workerThread(unsigned id) {
83 // emulate some work before sema acquisition
84 co_await guides[id].initial_delay();
85 // wait until a free sema slot is available
86 co_await sem.acquire();
87 // emulate some work while sema is acquired
88 co_await guides[id].occupy_sema();
89 sem.release();
90 co_await guides[id].visualize(id);
91}
92
93int main() {
94 io_context ctx;

Callers 1

mainFunction · 0.70

Calls 5

initial_delayMethod · 0.45
acquireMethod · 0.45
occupy_semaMethod · 0.45
releaseMethod · 0.45
visualizeMethod · 0.45

Tested by

no test coverage detected