Skip to content

tembleking/cchan

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cchan

A C++17 header-based library that implements Go-like channels.

Go relies on a concurrency model called CSP (Communicating Sequential Processes), to achieve this pattern of synchronization through Channels. Go core philosophy for concurrency is

Do not communicate by sharing memory; instead, share memory by communicating.

This library provides a set of types which methods behave like Go channels.

Installation

Import the header chan.h into your project to use it.

Usage

There are multiple examples in the examples folder.

#include <iostream>
#include <thread>
#include "chan.h"

// https://gobyexample.com/channels
int main() {

    chan<std::string> messages;

    std::thread([&]() {
        messages.put("ping");
    }).detach();

    auto msg = messages.get().value();
    std::cout << msg << std::endl;
}

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages