MCPcopy Create free account
hub / github.com/atollk/copper

github.com/atollk/copper @v1.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.1 ↗ · + Follow
242 symbols 433 edges 14 files 18 documented · 7% updated 2y agov1.1 · 2021-04-30★ 1785 open issues

Browse by type

Functions 183 Types & classes 59
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

logo


Build & Test codecov

Copper is a C++ library of a powerful queue object for communication between threads. It is based on Go's channels and follows the quote:

Don't communicate by sharing memory; share memory by communicating.

See docs/motivation.adoc for a high-level description of what Copper is capable of and how it stands out from previous C / C++ implementations of queues and Go-like channels.

Copper has... * only a single header to include. * no deadlocks; no race conditions; no undefined behavior; no polling. * support for multiple producers and multiple consumers. * an API based on that of std to avoid style clashes.


Quick Example

#include <future>
#include <iostream>
#include "copper.h"

copper::buffered_channel<int> channel_1;
copper::buffered_channel<int> channel_2;

void producer_1() {
    // Push the numbers 0 to 9 into channel_1.
    for (auto i = 0; i < 10; ++i) {
        (void) channel_1.push(i);
    }
    channel_1.close();
}

void producer_2() {
    // Push the numbers 0 to 9 into channel_2.
    for (auto i = 0; i < 10; ++i) {
        (void) channel_2.push(i);
    }
    channel_2.close();
}

void consumer() {
    // Until both channel_1 and channel_2 are closed, get the next message from either and print it.
    while (copper::select(
        channel_1 >> [](int x) { std::cout << "Message from producer 1: " << x << std::endl; },
        channel_2 >> [](int x) { std::cout << "Message from producer 2: " << x << std::endl; }
    ) == copper::channel_op_status::success);
}

int main() {
    const auto p1 = std::async(producer_1);
    const auto p2 = std::async(producer_2);
    const auto c = std::async(consumer);
    return 0;
}

More Information

API Reference

See docs/reference.adoc for a detailed reference of the public code interface.

Efficiency & Benchmarks

See docs/techdetails.adoc for technical information about efficiency and some benchmarks.


Conan, CPM, vcpkg

Not yet, but I'll see what I can do.

Core symbols most depended-on inside this repo

Shape

Method 125
Function 58
Class 57
Enum 2

Languages

C++100%

Modules by API surface

include/copper.h228 symbols
tests/template_instantiations.cpp12 symbols
tests/util.h2 symbols

For agents

$ claude mcp add copper \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page