Fundamentals 4 min read

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.

Laravel Tech Community
Laravel Tech Community
Laravel Tech Community
Release Notes and New Features of the ‘co’ C++ Coroutine Library

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.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

LibrarycoroutineC++code
Laravel Tech Community
Written by

Laravel Tech Community

Specializing in Laravel development, we continuously publish fresh content and grow alongside the elegant, stable Laravel framework.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.