Skip to content
/ cpp-csp Public

Minimalistic header-only library for channels and CSP (Communicating sequential process) in C++11.

Notifications You must be signed in to change notification settings

olahol/cpp-csp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cpp-csp

Minimalistic header-only library for channels and CSP (Communicating sequential process) in C++11.

Example

#include <iostream>

#include "csp.hpp"

int main() {
  csp::Channel<int> chan;
  csp::Scheduler scheduler;

  scheduler.spawn([&]() {
    for (int i = 1; i < 11; i++) {
      std::cout << "put " << i << std::endl;
      chan.put(i);
    }
    chan.put(0);
  });

  scheduler.spawn([&]() {
    while (true) {
      auto i = chan.get();
      if (i == 0) break;
      std::cout << "get " << i << std::endl;
    }
  });

  scheduler.join();

  return 0;
}

More examples can be found under examples/.

Contributing

Please run make tidy before submitting patches so that the code style is consistent.

About

Minimalistic header-only library for channels and CSP (Communicating sequential process) in C++11.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published