{"id":16608412,"url":"https://github.com/curve/channel","last_synced_at":"2025-10-29T16:32:21.089Z","repository":{"id":103639749,"uuid":"519532264","full_name":"Curve/channel","owner":"Curve","description":"🧵 A C++ implementation of Rust's std::sync::mpsc::channel","archived":false,"fork":false,"pushed_at":"2024-03-08T19:47:31.000Z","size":65,"stargazers_count":14,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-13T23:37:07.978Z","etag":null,"topics":["cpp","cpp17","cpp17-library","cpp20","cpp20-library","mpsc","mpsc-channel","threading"],"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/Curve.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2022-07-30T14:04:15.000Z","updated_at":"2025-02-12T14:03:55.000Z","dependencies_parsed_at":"2023-10-12T16:38:51.402Z","dependency_job_id":"0900369f-505f-4d47-9d95-4bd9300a8a1b","html_url":"https://github.com/Curve/channel","commit_stats":null,"previous_names":["curve/channel"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Curve%2Fchannel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Curve%2Fchannel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Curve%2Fchannel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Curve%2Fchannel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Curve","download_url":"https://codeload.github.com/Curve/channel/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238855898,"owners_count":19542101,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["cpp","cpp17","cpp17-library","cpp20","cpp20-library","mpsc","mpsc-channel","threading"],"created_at":"2024-10-12T01:26:06.727Z","updated_at":"2025-10-29T16:32:20.703Z","avatar_url":"https://github.com/Curve.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n# 🧵 channel\n\nA C++20 library that provides a rust like `std::sync::mpsc::channel` for inter-thread communication.\n\n\u003c/div\u003e\n\n# 📦 Installation\n\n\u003e [!NOTE]  \n\u003e This library requires a C++20 capable compiler.\n\u003e In case you need support for C++17 checkout commits prior to [6977815](https://github.com/Curve/channel/tree/6977815409b4c3c02d74a7aee3fc29f01d632feb)\n\n- FetchContent\n    ```cmake\n    include(FetchContent)\n    FetchContent_Declare(channel GIT_REPOSITORY \"https://github.com/Curve/channel\")\n\n    FetchContent_MakeAvailable(channel)\n    target_link_libraries(\u003cYourLibrary\u003e cr::channel)\n    ```\n- Git Submodule\n    ```bash\n    git submodule add \"https://github.com/Curve/channel\"\n    ```\n    ```cmake\n    # Somewhere in your CMakeLists.txt\n    add_subdirectory(\"\u003cpath_to_channel\u003e\")\n    target_link_libraries(\u003cYourLibrary\u003e cr::channel)\n    ```\n\n# 📒 Examples\n\n```cpp\n#include \u003cthread\u003e\n#include \u003ciostream\u003e\n\n#include \u003ccr/channel.hpp\u003e\n\nauto [sender, receiver] = cr::channel\u003cint, float\u003e();\n\n// Spawn off expensive computations\nstd::thread t1([sender = std::move(sender)]() mutable\n{\n    sender.send(expensive_computation_that_returns_int());\n    sender.send(another_expensive_computation_that_returns_float());\n});\n\n// Do some useful work for awhile\n\n// Let's see what that first answer was\nstd::cout \u003c\u003c receiver.recv_as\u003cint\u003e() \u003c\u003c std::endl;\n\n// Let's see what that second answer was\nstd::cout \u003c\u003c receiver.recv_as\u003cfloat\u003e() \u003c\u003c std::endl;\n```\n\n\u003e **Note**  \n\u003e This library also supports methods like `try_recv` and `recv_timeout`.\n\n\u003e For more examples see [tests](tests/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcurve%2Fchannel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcurve%2Fchannel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcurve%2Fchannel/lists"}