当前位置: 首页 > news >正文

灵川建设局网站网站做了301怎么查看跳转前网站

灵川建设局网站,网站做了301怎么查看跳转前网站,网店交易哪个平台好,浮梁网站建设C笔记之条件变量(Condition Variable)与cv.wait 和 cv.wait_for的使用 参考博客:C笔记之各种sleep方法总结 code review! 文章目录 C笔记之条件变量(Condition Variable)与cv.wait 和 cv.wait_for的使用1.条件变量&…

C++笔记之条件变量(Condition Variable)与cv.wait 和 cv.wait_for的使用

参考博客:C++笔记之各种sleep方法总结

code review!

文章目录

  • C++笔记之条件变量(Condition Variable)与cv.wait 和 cv.wait_for的使用
    • 1.条件变量(Condition Variable)
    • 2.cv.wait_for
    • 3.cv.wait
    • 4.cv.wait和cv.wait_for比较

1.条件变量(Condition Variable)

在这里插入图片描述

2.cv.wait_for

在这里插入图片描述

代码

#include <iostream>
#include <thread>
#include <mutex>
#include <condition_variable>std::mutex mtx;
std::condition_variable cv;
bool condition = false;void waitForCondition() {std::unique_lock<std::mutex> lock(mtx);// 等待一段时间,或直到条件满足if (cv.wait_for(lock, std::chrono::seconds(3), []{ return condition; })) {std::cout << "Condition is satisfied!" << std::endl;} else {std::cout << "Timed out waiting for condition." << std::endl;}
}void notifyCondition() {std::this_thread::sleep_for(std::chrono::seconds(2)); // 模拟一些操作{std::lock_guard<std::mutex> lock(mtx);condition = true;}cv.notify_one(); // 通知一个等待的线程
}int main() {std::thread t1(waitForCondition);std::thread t2(notifyCondition);t1.join();t2.join();return 0;
}

3.cv.wait

在这里插入图片描述

代码

#include <iostream>
#include <thread>
#include <mutex>
#include <condition_variable>std::mutex mtx;
std::condition_variable cv;
bool condition = false;void waitForCondition() {std::unique_lock<std::mutex> lock(mtx);cv.wait(lock, []{ return condition; }); // 等待条件满足std::cout << "Condition is satisfied!" << std::endl;
}void notifyCondition() {std::this_thread::sleep_for(std::chrono::seconds(2)); // 模拟一些操作{std::lock_guard<std::mutex> lock(mtx);condition = true;}cv.notify_one(); // 通知一个等待的线程
}int main() {std::thread t1(waitForCondition);std::thread t2(notifyCondition);t1.join();t2.join();return 0;
}

4.cv.wait和cv.wait_for比较

在这里插入图片描述

http://www.yayakq.cn/news/583276/

相关文章:

  • 做网站设计师能10年赚100万吗wordpress注册没有密码错误
  • 商品交易网站建设论文天津网站优化公司电话
  • 我是建造网站个人网站建设方案策划
  • 搭建微信网站网络广告和传统广告的区别
  • 仿win8网站如何拥有自己的专属域名
  • 郑州网站技术顾问简洁中文网站模板
  • 深圳网站建设 找猴王网络免费推广引流平台app
  • 网站建设目的确定百度资源平台
  • 福建建设执业注册管理中心网站网站界面设计的步骤
  • 怎么做类似淘宝一样的网站创建自己的网站
  • 2016做网站还赚钱吗濮阳新闻综合频道直播
  • 户外做爰网站wordpress rest api评论
  • 用dw做音乐网站系统的代码重庆智能建站模板
  • 企业如何找网络公司做网站微信官网网站
  • 网站建设三要素wordpress邮件订阅
  • 广州网站建设好评公司合肥做网站域名的公司
  • 网站建设入门到精通昂昂溪网站建设
  • 做网站的目的是啥中国建设银行网站用户注册
  • asp网站用ftp怎么替换图片容桂佛山做app网站
  • 哈尔滨建站网站关键词优化外包服务
  • 360检测网站开发语言的工具建设局网站建设方案书
  • 书本翻页 网站模板双语网站代码
  • 做交友类网站适合什么cms平台建网站
  • 企业网站前端建设如皋网站开发
  • 安康市建设局网站专业网站制作推荐
  • 网站建设硬件配置芒果视频怎样下载到本地
  • 自己主机做网站服务器吗世界杯观看入口
  • 凡科建站官网怎么样做网站需要几个程序
  • 企业网站建站那种好知名企业门户网站建设
  • 国外品牌网站京东网站的公司全名