Basically I am developing an opencv application. I have built OpenCV with_tbb option in cmake.
I would like to use intel tbb to run a parallel thread that at some intervals updates some global variables. Something like:
vector<int> mySharedVar;
void secondaryThreadFunction() {
while(true) {
Do some operations
And update mySharedVar if necessarily
usleep(1000);
}
}
int main() {
run in parallel secondaryThreadFunction;
in the master Thread keep doing something based on mySharedVar
while(true) {
do something;
}
}
How can I run secondaryThreadFunction() on another thread ?
Intel TBB is not meant to be used for that kind of purpose.
Quote from the Tutorial:
The thing you wanna do can be easily achived with either
boost::threador the C++11 threading features:Keep in mind to sync the access to any shared variables.