0

I am new to TBB. I met a problem, I hope you guys can give me some advise.

A class named Fruit:

Fruit.hpp:

class Fruit {
    protected :
        void A(...);
        void B(..);

    public :
        Fruit();
        ~ Fruit();
        void l1(....);
        void l2(...);
};

Fruit.cpp:

custom_TBB (...){
   //How to call the method A of Fruit?
}
class Fruit {
   ...
   Fruit::l1(....){
      tbb::task_scheduler_init init(numberOfThreads);
      parallel_for(tbb::blocked_range<int>(0,End,10000),custom_TBB (...));
   }
   ...
};

Because I need to use parallel method in the function of l1.
I am not sure whether my understanding of TBB is right to not?
I would like to know how can I make this works? Thank you first.

This is my idea:
1. I tried to declare custom_TBB inside the class Fruit, and implement it here, but failed.
2. I tried to define custom_TBB inside the function of l1, but also failed.

Leyla Lee
  • 466
  • 5
  • 19

1 Answers1

0

Ideally you should declare that tbb::task_scheduler_init init(numberOfThreads); as soon as you can in your program. I generally have it as pretty much the first thing in the main() function of anything I do using TBB.

timday
  • 24,582
  • 12
  • 83
  • 135
  • Yes, this is a good point, I need actually move it to the main class, thank you. And how about the problem? you have some good ideas? – Leyla Lee Jan 09 '16 at 15:58
  • For the other aspect, this might be useful: http://stackoverflow.com/q/10607215/24283 – timday Jan 09 '16 at 16:48
  • Thank you for your help! timeday, I think I need to know a lot basic stuff things – Leyla Lee Jan 12 '16 at 08:52