I have a project where we want to provide to use threads to speed up everything. We want to be able to call this function in individual threads:
Request& Filter::processRequest(Request& req)
Therefore I packed the function in lambda expression to have access to the return value.
I now get the following runtime error:
glibc detected ... double free or corruption (!prev): ...
When I uncomment the line where I add the thread to the group everything works fine.
boost::thread_group thread;
for (std::set<boost::shared_ptr<Filter> >::iterator i = sources_.begin();
i != sources_.end(); ++i) {
Request ret
thread.add_thread(new boost::thread(boost::lambda::var(ret) =
(*i)->processRequest(req)));
req+=ret;
...
}
thread.join_all();
What can be the reason for this runtime error. Or is there another way to put this function in individual threads?