摘要: 识别线程 线程表示类型为std::id可以通过两种方式进行检索 第一种可以通过std::thread 的对象成员函数get_id()来直接获取 第二种是在当前线程中调用std::get_id() void func(){ cout<<"print id in son process"<<std::t 阅读全文
posted @ 2023-01-03 17:29 ^江流儿^ 阅读(30) 评论(0) 推荐(0) 编辑
摘要: 转移线程的所有权 C++中有很多资源占用类型,例如std::ifstream,std::unique_ptr,std::thread都是可以移动,但是不能拷贝的 void func1(); void func2(); std::thread t1(func1); std::thread t2 = s 阅读全文
posted @ 2023-01-03 16:55 ^江流儿^ 阅读(30) 评论(0) 推荐(0) 编辑
摘要: 向线程函数传递参数 参数传递的基本形式如下所示: void f(int , std::string const & s); std::thread(f,3,"hello") std::thread 对传入的参数默认行为是复制,即使函数的形参是引用: void update_data_widget(w 阅读全文
posted @ 2023-01-03 16:31 ^江流儿^ 阅读(107) 评论(0) 推荐(0) 编辑
点击右上角即可分享
微信分享提示
🚀
回顶
收起
  1. 1 404 not found REOL
404 not found - REOL
00:00 / 00:00
An audio error has occurred.