摘要:
第十三章 补充知识、线程池浅谈、数量谈、总结 一、补充一些知识点1.1 虚假唤醒:notify_one或者notify_all唤醒wait()后,实际有些线程可能不满足唤醒的条件,就会造成虚假唤醒,可以在wait中再次进行判断解决虚假唤醒。解决:wait中要有第二个参数(lambda),并且这个la 阅读全文
posted @ 2022-09-01 15:51
〉外圆内方〈
阅读(37)
评论(0)
推荐(0)
摘要:
第十二节 windows临界区、其他各种mutex互斥量 一和二、windows临界区Windows临界区,同一个线程是可以重复进入的,但是进入的次数与离开的次数必须相等。C++互斥量则不允许同一个线程重复加锁。 windows临界区是在windows编程中的内容,了解一下即可,效果几乎可以等同于c 阅读全文
posted @ 2022-09-01 15:32
〉外圆内方〈
阅读(44)
评论(0)
推荐(0)
摘要:
std::atomic续谈、std::async深入谈 一、std::atomic续谈 #include <iostream> #include <thread> #include <atomic> using namespace std; std::atomic<int> g_count = 0; 阅读全文
posted @ 2022-09-01 14:53
〉外圆内方〈
阅读(91)
评论(0)
推荐(0)
摘要:
第十节 future其他成员函数、shared_future、atomic 一、std::future 的成员函数1、std::future_status status = result.wait_for(std::chrono::seconds(几秒));卡住当前流程,等待std::async() 阅读全文
posted @ 2022-09-01 11:09
〉外圆内方〈
阅读(37)
评论(0)
推荐(0)
摘要:
第九节、async、future、packaged_task、promise 本节内容需要包含头文件#include <future> 一、std::async、std::future创建后台任务并返回值 std::async是一个函数模板,用来启动一个异步任务,启动起来一个异步任务之后,它返回一个 阅读全文
posted @ 2022-09-01 10:16
〉外圆内方〈
阅读(26)
评论(0)
推荐(0)

浙公网安备 33010602011771号