An open API service indexing awesome lists of open source software.

https://github.com/tembleking/cchan

A C++17 header-based library that implements Go-like channels.
https://github.com/tembleking/cchan

channels concurrency concurrency-patterns concurrent-programming cpp cpp-library cpp17 golang library mit mit-license

Last synced: 8 months ago
JSON representation

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

Awesome Lists containing this project

README

          

# cchan

A C++17 header-based library that implements [Go](https://golang.org/)-like channels.

Go relies on a concurrency model called [CSP (Communicating Sequential Processes)](https://en.wikipedia.org/wiki/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.

```cpp
#include
#include
#include "chan.h"

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

chan 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](https://choosealicense.com/licenses/mit/)