Here is the example code:
#include <iostream>
#include <list>
#include <tbb/task.h>
#include <tbb/task_group.h>
#include <stdlib.h>
#include <boost/thread.hpp>
using namespace tbb;
long fib(long a)
{
if (a < 2) return 1;
return fib(a - 1) + fib(a - 2);
}
class PrintTask
{
public:
void operator()()
{
std::cout << "hi world!: " << boost::this_thread::get_id() << std::endl;
fib(50);
}
};
int main(int argc, char** argv)
{
task_group group;
for (int i = 0; i < 100; ++i)
{
group.run(PrintTask());
}
group.wait();
return(0);
}
Here I'm computing a big fibonacci sequence just to simulate non-blocking computation. I was specting that this code would generate more than two threads (my computer is a Core2Duo), but only the first and second tasks are called. This is the spected?