【发布时间】:2012-07-19 14:53:25
【问题描述】:
基本上我正在开发一个 opencv 应用程序。我在cmake 中构建了 OpenCV with_tbb 选项。
我想使用 intel tbb 运行一个并行线程,该线程每隔一段时间会更新一些全局变量。比如:
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;
}
}
如何在另一个线程上运行secondaryThreadFunction()?
【问题讨论】:
标签: c++ multithreading opencv tbb