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

培训视频网站丽水做企业网站的公司

培训视频网站,丽水做企业网站的公司,怎么做类似知乎的网站,linux类似wordpresssyncstream是C20中新增加的头文件#xff0c;提供了对同步输出流的支持#xff0c;即在多个线程中可安全地进行输出操作#xff0c;此头文件是Input/Output库的一部分。包括#xff1a; 1.std::basic_syncbuf#xff1a;是std::basic_streambuf的包装器(wrapper)syncstream是C20中新增加的头文件提供了对同步输出流的支持即在多个线程中可安全地进行输出操作此头文件是Input/Output库的一部分。包括 1.std::basic_syncbuf是std::basic_streambuf的包装器(wrapper)它将输出累积在其自己的内部缓冲区中并在销毁时以及明确请求时将其全部内容自动传输到包装的缓冲区以便它们显示为连续的字符序列。此类模板主要用于创建与多线程程序无缝协作的自定义流类。如果多个线程试图同时写入同一个流std::basic_syncbuf将确保每个线程的输出都以正确的顺序写入流而不会出现任何交错。 using syncbuf basic_syncbufchar; using wsyncbuf basic_syncbufwchar_t; 2.std::basic_osyncstream是std::basic_syncbuf的便捷包装器。它提供了一种机制来同步写入同一流的线程。 using osyncstream basic_osyncstreamchar_t; using wosyncstream basic_osyncstreamwchar_t; 测试代码如下 namespace {void func1(int id, std::ostream sync_out) {std::osyncstream sync_stream(sync_out);sync_stream thread id is running std::endl; }void func2(int id, std::ostream out) {out thread id is running std::endl; }void sync(std::ofstream file_out) {std::syncbuf sync_buf(file_out.rdbuf());std::ostream sync_out(sync_buf);constexpr int num_threads{ 10 };std::vectorstd::thread threads;for (int i 0; i num_threads; i)threads.emplace_back(func1, i, std::ref(sync_out));for (auto t : threads)t.join(); }void common(std::ofstream file_out) {constexpr int num_threads{ 10 };std::vectorstd::thread threads;for (int i 0; i num_threads; i)threads.emplace_back(func2, i, std::ref(file_out));for (auto t : threads)t.join(); }} // namespaceint test_syncstream() { #ifdef _MSC_VERstd::ofstream file_out1(../../../testdata/output1.txt);std::ofstream file_out2(../../../testdata/output2.txt); #elsestd::ofstream file_out1(testdata/output1.txt);std::ofstream file_out2(testdata/output2.txt); #endifif (!file_out1 || ! file_out2) {std::cerr fail to open file for writing std::endl;return -1;}sync(file_out1);common(file_out2);file_out1.close();file_out2.close();return 0; } 执行结果如下图所示每次输出并不完全一致output2.txt中输出是乱的而output1.txt中的输出是正常的 GitHubhttps://github.com/fengbingchun/Messy_Test
http://www.w-s-a.com/news/412330/

相关文章:

  • 厦门网站制作策划高中生做网站网页
  • 高端品牌网站建设在哪济南兴田德润优惠吗专业定制网站开发公司
  • 怎么做网站卖东西汽车网站排行榜前十名
  • 网站关键字没有排名只有单页面的网站怎么做seo
  • 网站流量盈利模式宝塔没有域名直接做网站怎么弄
  • 淡蓝色网站qq推广中心
  • 设计网站价格餐饮吸引客流的活动方案
  • 手机网站建设电话百度搜索量
  • 条件查询 php网站源码中国白云手机网站建设
  • 网上注册公司流程及材料班级优化大师免费下载电脑版
  • 应用网站如何做营销型网站的重要特点
  • 怎么样百度搜到自己的网站加强社区网站建设
  • 建设网站所需技术wordpress延时加载js
  • 网站建设沈阳搜云seo
  • 怎么申请免费的网站空间微信公众平台注册收费吗
  • 东营网站搭建最基本的网站设计
  • 网站建设技术的发展最近的国际新闻大事
  • 德州有名的网站建设公司网站如何做引流
  • 建设一个收入支出持平的网站网络推广计划书格式
  • 什么是网站黑链全球新冠疫苗接种率
  • 网站开发 chrome gimp网站不备案做seo没用
  • 织梦校园招生网站源码沪佳哪个好
  • 建设企业网站可信度软件产品如何做网站推广
  • 网站建设企业号助手贵阳景观设计公司
  • 网站开发第三方建设银行个人网站显示不了
  • 无锡兼职做网站郑州网站建设搜索优化
  • iis禁止通过ip访问网站品牌策划案例ppt
  • 电子商务网站建设实习seo黑帽优化
  • 如何做好网站建设销售闸北集团网站建设
  • 重庆装饰公司北京官网seo推广