0

Suppose there are some worker objects which contains some internal resource such as socket. Those worker objects are created at the program startup and destroyed at program exit. The main thread will pass an object ID to one of the worker object. Then the worker will process the object with that ID and send the result through socket. What I want is to let those workers run parallely. Is there any of TBB component that can serve for this purpose?

Michael D
  • 1,449
  • 5
  • 18
  • 31

1 Answers1

0

But you can easily create a thread class which accept the worker as an constructor parameter. Create a thread object for each worker object and start these threads then it is done.

Yong Lai
  • 56
  • 3
  • If so, then I need to create a message queue in the worker object that I don't want. – Michael D Apr 02 '13 at 10:26
  • I think you only need a manager in the main thread to manage the pool of work objects. When the main thread needs to pass an object ID to one of the work objects, the manager will pick up a free work object to handle the job, after the job is done, the work object will be tagged as free again. – Yong Lai Apr 02 '13 at 15:14