Skip to content

mgerhardy/Beryl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Beryl - A green thread library

Build Status

beryl icon

Coding with beryl

One of the main aims of the beryl library is it to bring the concurrency features of erlang and the go programming language to c++.

#include <iostream>
#include "beryl.hpp"


int main (){
  beryl::create([] () {
    auto info = beryl::utils::getInfo();
    std::cout << "Hello from thread: " << info.name << std::endl;
  } );

  beryl::go();  
}

Beryl offers support for c++ closures or normal functions.

#include <iostream>
#include "beryl.hpp"


void helloWorld() {
  std::cout << "Hello from beryl" << std::endl;
}

int main (){
  beryl::create([] () {
    auto info = beryl::utils::getInfo();
    std::cout << "Hello from thread: " << info.name << std::endl;
  }, "First_thread");

  beryl::create(&helloWorld, "helloWorld-thread");

  beryl::go();  
}

This outputs:

Hello from thread: First_thread
Hello from beryl

Extended memory control over your threads

Beryl offers you to limit the stack size or the allocated memory on the heap for each thread

Stack memory

Still WIP 🚧

Each thread gets its own stack with a size of 10K. You can provide a callback method which gets invoked when your thread runs out of memory.

It is also possible to resize the actual stack. This is not considered to be good practice because the old stack data needs to be copied into the new stack.

Heap memory

Still WIP 🚧

Beryl overwrites the default STL memory allocator so that it can also monitor the heap consuming behaviour of your threads.

TODOs 🔥

  • save and restore all volatile registers
  • allow return values and a better support for parameters 🚧
  • implement IO functions
  • implement event/messaging system for communication between threads

About

Beryl - A green thread library

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors