'Update class objects within threads
Here's the gist of what I'm trying to do:
// Wrapper for thread call (?)
void doUpdateWrap(MyClass& obj, <args>) {
obj.doUpdate(<args>)
}
// Make vector of class objects
std::vector<MyClass> vec;
for (int i=0; i<numObj; i++) {
tmp = MyClass();
vec.push_back(tmp);
}
// Update all the objects in parallel with threads
std::vector<std::thread> myThreads;
for (int i=0; i<numObj; i++) {
myThreads.push_back(std::thread(&doUpdateWrap, vec[i], <someArgs>)
}
<join myThreads>
But the compiler is unhappy. What's the right way?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
