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.
- Host: GitHub
- URL: https://github.com/tembleking/cchan
- Owner: tembleking
- License: mit
- Created: 2019-05-01T18:55:28.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2020-05-16T10:22:51.000Z (almost 6 years ago)
- Last Synced: 2025-04-06T23:34:29.858Z (12 months ago)
- Topics: channels, concurrency, concurrency-patterns, concurrent-programming, cpp, cpp-library, cpp17, golang, library, mit, mit-license
- Language: C++
- Size: 9.77 KB
- Stars: 5
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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/)