Visual Studio13创建线程和优化进程

Visual Studio13 Creating Threads and Optimizing Process

本文关键字:优化 进程 线程 Studio13 创建 Visual      更新时间:2023-10-16

我在VS13中编写多个线程

函数声明:

void getColorImage(HANDLE &colorEvent, HANDLE &colorStreamHandle, Mat &colorImage);
void getDepthImage(HANDLE &depthEvent, HANDLE &depthStreamHandle, Mat &depthImage);
void getSkeletonImage(HANDLE &skeletonEvent, Mat &skeletonImage, Mat &colorImage, Mat &depthImage, ofstream& myfile);
int main()
{
    // this is inside a while loop
    std::thread first(getColorImage, colorEvent, colorStreamHandle, colorImage);
    std::thread second(getDepthImage, depthEvent, depthStreamHandle, depthImage);
    std::thread third(getSkeletonImage, skeletonEvent, skeletonImage, colorImage, depthImage, myfile);
    first.join();
    second.join();
    third.join();
 }

但是,我得到一个错误:

错误1错误C2280: 'std::basic_ofstream>::basic_ofstream(const std::basic_ofstream> &)':试图引用已删除的函数c:program files (x86)microsoft visual studio 12.0vcincludetype_traits 1545 1 skeleton_rgbdepth_dataprocetion2013

我不知道为什么……有人能帮帮我吗?

std::thread构造函数与std::bind一样,按值获取其所有参数。但是std::ofstream有一个delete d复制构造函数,因此出现错误。

std::ref包裹所有应该通过引用传递的参数