您现在的位置是:主页 > news > 北京做网站制作公司/杭州seo公司排名

北京做网站制作公司/杭州seo公司排名

admin2025/6/22 11:59:52news

简介北京做网站制作公司,杭州seo公司排名,做书网站 时光,知名的网站建设1 std::thread传入引用值需要使用std::ref std::ref的说明: Constructs an object of the appropriate reference_wrapper type to hold a reference to elem. 其实主要是,如果要向thread传参的时候,该参数在线程内会被修改,需要…

北京做网站制作公司,杭州seo公司排名,做书网站 时光,知名的网站建设1 std::thread传入引用值需要使用std::ref std::ref的说明: Constructs an object of the appropriate reference_wrapper type to hold a reference to elem. 其实主要是,如果要向thread传参的时候,该参数在线程内会被修改,需要…

1 std::thread传入引用值需要使用std::ref

std::ref的说明: Constructs an object of the appropriate reference_wrapper type to hold a reference to elem.
其实主要是,如果要向thread传参的时候,该参数在线程内会被修改,需要用这个ref作为一个wrapper将对象包裹成为一个引用然后传入。

void main() {while(1){...<省略>...if (!initializedFlag) {initializedFlag = true;// viewThd = new std::thread(viewThread, camVecToDraw); // wrong wayviewThd = new std::thread(viewThread, std::ref(camVecToDraw)); // right way}...<省略>...addCamToDrawVec(imgData.image, camVecToDraw);camVecToDraw;}viewThd.join();delete viewThd;viewThd = nullptr;
}void viewThread(std::vector<pangolin::OpenGlMatrix>& camVecToDraw) {while(!shallQuit()) {// render some cameras according to camVecToDraw...<省略>...}
}