c++11 - How to refer Lambda to std::function<void()> -


iam building threadpool boost raycaster performance.

therefore threadpool has job queue:

std::vector<std::function<void()>> jobs; 

and public function add jobs threadpool.

void threadpool::executejob(std::function<void()> job) {   std::unique_lock<std::mutex> lockjobs(this->lockjobs);   this->jobs.push_back(job); } 

the function want refer threadpool since following:

void meshscene::castrays(const ray& ray, const int raycount, const matrixf& rot,                           std::vector<intersectionresult>& raycollection) {     // perform raycasts...     raycollection.push_back(intersectionresult);   } } 

the raycollection member of class call executejob(std::function<void()> job) function.

now try refer lambda

threadpool.executejob([ray, raycount, rotation, this] () { castrays(ray, raycount, rotation, std::ref(this->testintersectioncollection)); }); 

i confusing errors , think lamdba expression doesn't make sense. ideas?

or know better solution instead of collecting jobs std::function?

sorry missing response side. figured out solution forgot post it. here how did it:

the threadpool function:

void executejob(std::function<void()> job); 

the function call:

void castrays(std::vector<result>* resultcollection) 

the call threadpool:

threadpool.executejob([this] () { castrays(&this->intersectioncollectionone); }); 

Comments

Popular posts from this blog

android - Pass an Serializable object in AIDL -

How to provide Authorization & Authentication using Asp.net, C#? -

How to use Authorization & Authentication in Asp.net, C#? -