compat.libcoro
#includelibcoro — C++20 coroutine tasks, generators, thread pool and awaitable synchronisation
#include <coro/event.hpp>
mcpp add compat.libcoro@0.16.0
用法
来自本仓库自己的测试项目 —— CI 真的编译并运行过,不是为了网站写的。
// Behavioral test — compat.libcoro actually schedules coroutines.
//
// Every assertion here needs a resumed coroutine to be true, so a package that
// compiled the headers but linked none of the eight core TUs fails: the
// thread_pool, event, mutex and sync_wait entry points all live in those.
//
// Networking is deliberately untouched — see the descriptor. `coro/coro.hpp`
// is NOT included for the same reason; it opens the net/ headers behind
// LIBCORO_FEATURE_NETWORKING, which this build does not define.
//
// No `import std;`: libcoro's headers are textual over the standard library.
#include <coro/event.hpp>
#include <coro/generator.hpp>
#include <coro/mutex.hpp>
#include <coro/sync_wait.hpp>
#include <coro/task.hpp>
#include <coro/thread_pool.hpp>
#include <coro/when_all.hpp>
#include <atomic>
#include <cstdio>
#include <vector>
// …
tests/examples/libcoro/tests/coroutines.cpp · 项目 tests/examples/libcoro
构建
- targets
libcoro (lib)- language
c++23- C standard
c11- import std
- no
- include dirs
*/include, mcpp_generated
源文件 (8)
*/src/detail/task_self_deleting.cpp*/src/condition_variable.cpp*/src/default_executor.cpp*/src/event.cpp*/src/mutex.cpp*/src/semaphore.cpp*/src/sync_wait.cpp*/src/thread_pool.cpp
生成的文件
mcpp_generated/coro/export.hpp