dimanche 18 octobre 2020

How to have multiple fibers in C++ -- like a vector of fibers

I want to have multiple fibers running like so.

#include <boost/fiber/fiber.hpp>    

#include <vector>

std::vector<boost::fibers::fiber> runningFibers;
for (int i = 0; i < 10; i++) {
   runningFibers.emplace_back(boost::fibers::fiber([&](){std::cout << "Hello Worrld" << std::endl;));
}

However this causes some kind of memory leak when I run with valgrind. How do I do what I am trying to do here but without memory leaks. I looked at boost's documentation but got confused.

Aucun commentaire:

Enregistrer un commentaire