SkillAgentSearch skills...

Channel

๐Ÿงต A C++ implementation of Rust's std::sync::mpsc::channel

Install / Use

/learn @Curve/Channel
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

<div align="center">

๐Ÿงต channel

A C++20 library that provides a rust like std::sync::mpsc::channel for inter-thread communication.

</div>

๐Ÿ“ฆ Installation

[!NOTE]
This library requires a C++20 capable compiler. In case you need support for C++17 checkout commits prior to 6977815

  • FetchContent
    include(FetchContent)
    FetchContent_Declare(channel GIT_REPOSITORY "https://github.com/Curve/channel")
    
    FetchContent_MakeAvailable(channel)
    target_link_libraries(<YourLibrary> cr::channel)
    
  • Git Submodule
    git submodule add "https://github.com/Curve/channel"
    
    # Somewhere in your CMakeLists.txt
    add_subdirectory("<path_to_channel>")
    target_link_libraries(<YourLibrary> cr::channel)
    

๐Ÿ“’ Examples

#include <thread>
#include <iostream>

#include <cr/channel.hpp>

auto [sender, receiver] = cr::channel<int, float>();

// Spawn off expensive computations
std::thread t1([sender = std::move(sender)]() mutable
{
    sender.send(expensive_computation_that_returns_int());
    sender.send(another_expensive_computation_that_returns_float());
});

// Do some useful work for awhile

// Let's see what that first answer was
std::cout << receiver.recv_as<int>() << std::endl;

// Let's see what that second answer was
std::cout << receiver.recv_as<float>() << std::endl;

Note
This library also supports methods like try_recv and recv_timeout.

For more examples see tests

View on GitHub
GitHub Stars23
CategoryDevelopment
Updated5mo ago
Forks3

Languages

C++

Security Score

92/100

Audited on Oct 14, 2025

No findings