Geez, I don't even know where to begin, I have more than 400 lines of code in several header/source files.
I'll show you how I tackled my threading, and we can go from there:
(Irrelevant code is removed)
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
~~~~
boost::thread_group threadGroup;
threadGroup.create_thread(masterThread(0));
for(int i = 0; i < NTHREADS; i++)
{
threadGroup.create_thread(threads(i));
}
threadGroup.join_all();
~~~~
|
The number of threads is set using a preprocessor directive:
#define NTHREADS [X]
Where [X] is the number of threads.
I have a loop set to create a number of worker threads, and a master thread that checks the state of the variables processed for a trigger event that ends the loop.
Note that no performance gain is seen between using two threads or two hundred. No matter what I do, only one core is used by the application, and no threading benefits are seen.
As I said, this is an embarrassingly parallel task, so there should be a noticeable performance gain if threading is executed correctly.