Search code examples
c++boostfiber

Why boost::fiber blocks?


I'm trying to play with boost::fiber library but I have the problem with the "Hello, World" example. In the following code the program flow blocks after the fiber is finished and the main function never returns.

#include <iostream>
#include <boost/fiber/all.hpp>

using namespace std;

void helloFiber()
{
  cout << "Hello, boost::fiber" << endl;
}

int main()
{
  boost::fibers::fiber f(helloFiber);

  cout << "Before join." << endl;
  f.join();
  cout << "After join." << endl;

  return 0;
}

The result is:

Before join.
Hello, boost::fiber

I built boost::fiber current develop branch with the current develop branch of modular-boost. Is this behavior bug in the current implementation or there is something wrong in my usage?


Solution

  • your test app prints:

    Before join. Hello, boost::fiber After join.

    maybe you've checkout an broken version from branch develop