Release Notes and New Features of the ‘co’ C++ Coroutine Library
This document outlines the latest release of the C++ coroutine library “co”, providing GitHub links, reference documentation, new features such as xrepo, vcpkg integration, defer, channel, waitgroup, scheduler APIs, API changes, and several bug fixes.
The "co" C++ coroutine library has been updated; the source code is available at https://github.com/idealvin/co with Chinese and English reference documentation hosted on GitHub and Gitee.
New features include the xrepo installer, VCPKG support, a defer utility similar to Go's defer, a channel implementation, and a waitgroup analogous to Go's sync.WaitGroup. Example usages are:
sh
xrepo install -f "openssl=true,libcurl=true" co sh
vcpkg install co:x64-windows
# http & ssl support
vcpkg install co[libcurl,openssl]:x64-windows cpp
#include "co/defer.h"
Timer t;
defer(LOG << "time elapse: " << t.us() << "us"); cpp
#include "co/co.h"
DEF_main(argc, argv) {
co::Chan<int> ch;
go([ch]() { ch << 7; });
int v = 0;
ch >> v;
LOG << "v: " << v;
return 0;
} cpp
#include "co/co.h"
DEF_main(argc, argv) {
FLG_cout = true;
co::WaitGroup wg;
wg.add(8);
for (int i = 0; i < 8; ++i) {
go([wg]() {
LOG << "co: " << co::coroutine_id();
wg.done();
});
}
wg.wait();
return 0;
}Additional API changes add void flag::init(const fastring& path);, rename the global Closure to co::Closure, improve co::Event, co::Mutex, and co::Pool to support copy construction and value capture in lambdas, and make co::close() callable from any context. Partial support for MinGW is added, though coroutine features are not yet functional on that platform.
Bug fixes address a file‑read/write issue when handling data larger than 4 GB in fs::file, correct error messages for HTTP client connection timeouts, and resolve a linking problem reported in issue #165.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Laravel Tech Community
Specializing in Laravel development, we continuously publish fresh content and grow alongside the elegant, stable Laravel framework.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
