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

网站建站的费用整站关键词排名优化

网站建站的费用,整站关键词排名优化,网站建设网站建设,jsp网站开发实例<syncstream>是C20中新增加的头文件&#xff0c;提供了对同步输出流的支持&#xff0c;即在多个线程中可安全地进行输出操作&#xff0c;此头文件是Input/Output库的一部分。包括&#xff1a; 1.std::basic_syncbuf&#xff1a;是std::basic_streambuf的包装器(wrapper)&…

      <syncstream>是C++20中新增加的头文件,提供了对同步输出流的支持,即在多个线程中可安全地进行输出操作,此头文件是Input/Output库的一部分。包括:

      1.std::basic_syncbuf:是std::basic_streambuf的包装器(wrapper),它将输出累积在其自己的内部缓冲区中,并在销毁时以及明确请求时将其全部内容自动传输到包装的缓冲区,以便它们显示为连续的字符序列。此类模板主要用于创建与多线程程序无缝协作的自定义流类。如果多个线程试图同时写入同一个流,std::basic_syncbuf将确保每个线程的输出都以正确的顺序写入流,而不会出现任何交错。

using syncbuf  = basic_syncbuf<char>;
using wsyncbuf = basic_syncbuf<wchar_t>;

      2.std::basic_osyncstream:是std::basic_syncbuf的便捷包装器。它提供了一种机制来同步写入同一流的线程。

using osyncstream  = basic_osyncstream<char_t>;
using wosyncstream = basic_osyncstream<wchar_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::vector<std::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::vector<std::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中的输出是正常的

      GitHub:https://github.com/fengbingchun/Messy_Test

http://www.wangmingla.cn/news/135557.html

相关文章:

  • 用网站建设费用网络营销推广服务商
  • 安徽华夏网站建设seo自然搜索优化排名
  • 做网站需要网络服务器国外推广网站
  • 人力资源网站开发说明书北京做网络优化的公司
  • 本地网站更新不了 vps登陆可以谁能给我个网址
  • 大型网站构建实施方案软文批发网
  • 网站开发技术孵化网站关键词优化的步骤和过程
  • 网站建设实训报告模板广州谷歌seo公司
  • 医疗器械做网站到哪里先备案百度怎么推广自己的信息
  • 推荐聊城做网站百度首页网址
  • 网站建设的优点和缺点浏览器直接进入网站的注意事项
  • 新建南昌网站建设公司网络推广外包哪个公司做的比较好
  • 中企动力是怎么建设网站的软件开发工程师
  • 商城网站建设需要什么团队什么是网络销售
  • 凡科快图怎么制作图片seo狂人
  • 网站设计编程有哪些企业网络营销推广方法
  • 深圳专门做兼职的网站国外seo大神
  • 网站策划公司如何提高网站的搜索排名
  • 2017做电商做什么网站湘潭网站seo磐石网络
  • 威海外贸网站建设电话抖音权重查询工具
  • 做购物网站 推广广州搜发网络科技有限公司
  • 网站首页大图的尺寸友情链接买卖代理
  • 网站长尾词怎么做seo扣费系统
  • wordpress可以做企业网站百度网盘手机app下载安装
  • 邱县做网站网站收录服务
  • dw软件入门教程关键词优化排名网站
  • 城市建设管理网站友情链接论坛
  • 国内外优秀室内设计案例优化设计五年级下册数学答案
  • 网站建设安全性信阳seo优化
  • 安丘做网站网络营销策划书1000字