{"id":49718829,"url":"https://github.com/hudson-trading/corral","last_synced_at":"2026-05-08T22:14:32.362Z","repository":{"id":216714086,"uuid":"742063418","full_name":"hudson-trading/corral","owner":"hudson-trading","description":"Lightweight structured concurrency for C++20","archived":false,"fork":false,"pushed_at":"2026-02-06T10:56:34.000Z","size":410,"stargazers_count":158,"open_issues_count":1,"forks_count":22,"subscribers_count":3,"default_branch":"master","last_synced_at":"2026-02-06T18:30:36.191Z","etag":null,"topics":["async","asynchronous","asynchronous-programming","concurrency","coroutines","cpp","cpp20","cpp20-coroutine","structured-concurrency"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hudson-trading.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-01-11T17:28:31.000Z","updated_at":"2026-02-06T10:56:37.000Z","dependencies_parsed_at":null,"dependency_job_id":"d44efff6-8b79-4438-a01b-92ba357e15f6","html_url":"https://github.com/hudson-trading/corral","commit_stats":null,"previous_names":["hudson-trading/corral"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/hudson-trading/corral","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hudson-trading%2Fcorral","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hudson-trading%2Fcorral/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hudson-trading%2Fcorral/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hudson-trading%2Fcorral/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hudson-trading","download_url":"https://codeload.github.com/hudson-trading/corral/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hudson-trading%2Fcorral/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32799498,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-08T08:22:46.396Z","status":"ssl_error","status_checked_at":"2026-05-08T08:22:45.650Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["async","asynchronous","asynchronous-programming","concurrency","coroutines","cpp","cpp20","cpp20-coroutine","structured-concurrency"],"created_at":"2026-05-08T22:14:28.616Z","updated_at":"2026-05-08T22:14:32.357Z","avatar_url":"https://github.com/hudson-trading.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Corral — lightweight structured concurrency for C++20\n\n## Purpose\n\nCorral is a C++ concurrency library that implements cooperative\nsingle-threaded multitasking using C++20 coroutines. Its design is\nbased on our experience using coroutines to support asynchronous I/O in\nreal-world production code. Users familiar with the\n[Trio](https://github.com/python-trio/trio) library for Python will\nfind a lot here that looks familiar. A few of corral's design goals are:\n\n* ***[Structured concurrency](https://vorpus.org/blog/notes-on-structured-concurrency-or-go-statement-considered-harmful/)***\n  baked in: tasks are organized into a tree of parent-child\n  relationships, where the parent is responsible for waiting for its\n  children to finish and propagates any exceptions that the children\n  raise.  This allows certain crucial features like resource\n  management, task cancellation, and error handling to Just Work™ the\n  way people would expect them to.\n\n* ***I/O and event loop agnostic***: like quite a few other\n  companies with decades of history, we have our own homegrown\n  implementations of asynchronous I/O and event loops. We wanted\n  to be able to use coroutines with them, as well as pretty much\n  any other existing solution for asynchronous I/O (such as Asio,\n  libuv, or libevent).\n\n* ***Bridging with callbacks***: the majority of existing code uses\n  callbacks for asynchronous I/O; rewriting all of it from the ground\n  up, while entertaining, tends not to be a realistic option.  We\n  needed a way to have coroutine \"pockets\" in the middle of legacy\n  code, being able call or be called from older code that's still\n  using callbacks — so people could onboard gradually, one small piece\n  at a time, getting benefit from these small pieces immediately.\n\nCorral focuses on **single-threaded** applications because this results in\na simpler design, less overhead, and easier reasoning about\nconcurrency hazards. (In a single-threaded environment with\ncooperative multitasking, you know that you have exclusive access to\nall state in between `co_await` points.)  Multiple threads can each\nrun their own \"corral universe\", as long as tasks that belong to\ndifferent threads do not interact with each other.\n\n## Motivating example\n\nThe code snippet below establishes a TCP connection to one of two\nremote servers, whichever responds first, and returns the socket.\n\n```cpp\nusing tcp = boost::asio::tcp;\nboost::asio::io_service io_service;\n\ncorral::Task\u003ctcp::socket\u003e myConnect(tcp::endpoint main, tcp::endpoint backup) {\n    tcp::socket mainSock(io_service), backupSock(io_service);\n\n    auto [mainErr, backupErr, timeout] = co_await corral::anyOf(\n        // Main connection attempt\n        mainSock.async_connect(main, corral::asio_nothrow_awaitable),\n\n        // Backup connection, with staggered startup\n        [\u0026]() -\u003e corral::Task\u003cboost::system::error_code\u003e {\n            co_await corral::sleepFor(io_service, 100ms);\n            co_return co_await backupSock.async_connect(\n                backup, corral::asio_nothrow_awaitable);\n        },\n\n        // Timeout on the whole thing\n        corral::sleepFor(io_service, 3s));\n\n    if (mainErr \u0026\u0026 !*mainErr) {\n        co_return mainSock;\n    } else if (backupErr \u0026\u0026 !*backupErr) {\n        co_return backupSock;\n    } else {\n        throw std::runtime_error(\"both connections failed\");\n    }\n}\n```\n\n## Prerequisites and installation\n\nCorral is a header-only library, so you can just copy the `corral`\nsubdirectory into your project and start using it. It does not depend\non any external libraries on its own. If you want to build the tests,\nyou will need Catch2, and the examples require various other I/O libraries.\n\nObviously a recent C++ compiler is required. The library has been tested on gcc-11\nand clang-15+, and was known to occasionally ICE gcc-10.2 back in the day.\n\nTo allow people to explore more easily and quickly get something running,\ncorral ships with support for Asio out of the box: pass\n`corral::asio_awaitable` (or `corral::asio_nothrow_awaitable`) to any Asio async\noperation to make it return a corral-compatible awaitable (you need\nto #include `corral/asio.h` or `corral/asio-standalone.h`, depending on whether\nyou use boost or standalone version of Asio). Other I/O frameworks\nor event loops can also be adapted to corral relatively straightforwardly.\n`examples/qt_echo_server.cc` shows bridging of corral and Qt.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhudson-trading%2Fcorral","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhudson-trading%2Fcorral","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhudson-trading%2Fcorral/lists"}