I'm very new to multithreading and found some thread pooling examples online and made a class out of them: https://pastebin.com/pWddf9m0
I can get it to do some jobs with a simple example:
int j = 0;
for (int i = 0; i < 4; i++) {
this->pool.Queue([&]() {
j++;
std::cout << "\n " << j;
});
}
Which sort of works, it out puts:
1
3
4
4
But for larger jobs, like setting color data from a file, it crashes after jobs and I get a read access violation from the vector its filling.
So, with all that, what am I doing wrong or is the POOL object even correct? And how about the accuracy issue?
I'll gladly provide more info as needed. Hopefully I explained my problem right.
Pastebin
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
)