dimanche 10 février 2019

can I create threads in a function outside main in C++?

I want to create threads in a function, that takes in an RGBA image vector and process it into gray scale vector. I declared the thread library in my source file. I also tried creating threads from within main function and it worked. What I want is to make 4 threads in a different function that is called in main, I initialized it as follows:

thread t1 (parallel_grayDownSampled,0, image, temp1, image.size() / 4);
t1.join();

//this is the function signature:
void parallel_grayDownSampled(int j, vector <unsigned char> &image, vector <unsigned char> &grayImage, int end)

The error message says Error C2672 'std::invoke': no matching overloaded function found.

Aucun commentaire:

Enregistrer un commentaire