摘要:
识别线程 线程表示类型为std::id可以通过两种方式进行检索 第一种可以通过std::thread 的对象成员函数get_id()来直接获取 第二种是在当前线程中调用std::get_id() void func(){ cout<<"print id in son process"<<std::t 阅读全文
摘要:
转移线程的所有权 C++中有很多资源占用类型,例如std::ifstream,std::unique_ptr,std::thread都是可以移动,但是不能拷贝的 void func1(); void func2(); std::thread t1(func1); std::thread t2 = s 阅读全文
摘要:
向线程函数传递参数 参数传递的基本形式如下所示: void f(int , std::string const & s); std::thread(f,3,"hello") std::thread 对传入的参数默认行为是复制,即使函数的形参是引用: void update_data_widget(w 阅读全文