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

网站建设工作的函代写文章质量高的平台

网站建设工作的函,代写文章质量高的平台,阿拉尔市建设局网站,用dw做动态网站乱码怎么弄休眠函数简介1: 让线程休眠一段时间1.1:std::chrono 的时钟 clock简介 C11 之前并未提供专门的休眠函数,C语言的 sleep、usleep函数其实是系统提供的函数,不同的系统函数的功能还要些差异。 在Windows系统中,sleep的参数是毫秒 …

休眠函数

  • 简介
  • 1: 让线程休眠一段时间
    • 1.1:std::chrono 的时钟 clock

简介

C++11 之前并未提供专门的休眠函数,C语言的 sleep、usleep函数其实是系统提供的函数,不同的系统函数的功能还要些差异。

  • 在Windows系统中,sleep的参数是毫秒
  • sleep(2*1000); // sleep for 2 seconds
  • 在类Unix系统中,sleep()函数的单位是秒。

sleep(2); // sleep for 2 seconds

  • 但是从C++11起,C++标准库提供了专门的线程休眠函数,使得你的代码可以独立于不同的平台。

std::this_thread::sleep_for
std::this_thread::sleep_untill

1: 让线程休眠一段时间

std::this_thread::sleep_for : 用于Block 当前线程一段时间。

函数原型:
template<class Rep, class Period>
void sleep_for(const std::chrono::duration<Rep,Period>& sleep_duration);
比如:想要一个线程休眠 100ms
std::this_thread::sleep_for(std::chrono::millseconds(100));

#include <iostream>
#include <chrono>
#include<thread>int main(){std::cout << "start wait......"<< std::endl;/**在C++11 中 chrono中有三种时钟:system_clock, steady_clock 和 high_resolution_clocksystem_clock : 是不稳定的,因为时钟是可调的。它可以输出当前时间距离:1970年1月1日00:00的毫秒数它一般用于需要得到 :绝对时点的场景。steady_clock:一般用在需要得到时间间隔的场景。high_resolution_clock:介于上面两者之间,时间精度比steady_clock()更精确*/auto start = std::chrono::high_resolution_clock::now();std::this_thread::sleep_for(std::chrono::milliseconds(2000));auto end = std::chrono::high_resolution_clock::now();std::chrono::duration<double,std::milli> elapsed = end-start;std::cout<< "waited: "<< elapsed.count()<< " ms"<< std::endl;}
打印结果 
tart wait......
waited: 2000.06 ms

1.1:std::chrono 的时钟 clock

std::chrono是C++11引入的日期时间处理库,其中包含了3种时钟: system_clock,steady_clock ,high_resolution_clock 。如果需要使用高精度的时间,很自然就会想到使用 high_resolution_clock 。

1. system_clock: 用在需要得到绝对时间点的场景。

void test_system_clock(){auto curTime = std::chrono::system_clock::now();std::time_t tt = std::chrono::system_clock::to_time_t(curTime);std::cout<< tt << " seconds from 1970-01-01 00:00:00 UTC"<< std::endl;
}
int main(){test_system_clock();
}// 打印结果:1677597162 seconds from 1970-01-01 00:00:00 UTC
  1. steady_clock: 用在需要得到时间间隔,并且这个时间间隔不会因为修改系统时间而受到影响的场景
void test_steady_clock(){auto curTime = std::chrono::steady_clock::now();// do somethingstd::this_thread::sleep_for(std::chrono::milliseconds(3000));auto curTime2 = std::chrono::steady_clock::now();std::chrono::duration<double,std::milli> spendTime = (curTime2-curTime);std::cout<< "耗时:"<< spendTime.count()<< "秒"<< std::endl;
}int main(){test_steady_clock();
}// 打印:耗时:3000.07秒

文章转载自:
http://caesaropapism.rnds.cn
http://probing.rnds.cn
http://petn.rnds.cn
http://vasectomy.rnds.cn
http://aspersion.rnds.cn
http://cingulate.rnds.cn
http://paedomorphosis.rnds.cn
http://chinar.rnds.cn
http://despumation.rnds.cn
http://tutu.rnds.cn
http://ventless.rnds.cn
http://tourist.rnds.cn
http://semiofficially.rnds.cn
http://mongolian.rnds.cn
http://sisterless.rnds.cn
http://tertius.rnds.cn
http://coquette.rnds.cn
http://hydroxonium.rnds.cn
http://assam.rnds.cn
http://sleave.rnds.cn
http://prizewinning.rnds.cn
http://gusset.rnds.cn
http://incommunicable.rnds.cn
http://newsgirl.rnds.cn
http://snowman.rnds.cn
http://scoundrelly.rnds.cn
http://unchaste.rnds.cn
http://pluricellular.rnds.cn
http://regs.rnds.cn
http://moisher.rnds.cn
http://constellation.rnds.cn
http://mamillated.rnds.cn
http://phenomenize.rnds.cn
http://unhandsomely.rnds.cn
http://intelligential.rnds.cn
http://unrip.rnds.cn
http://delusterant.rnds.cn
http://cathole.rnds.cn
http://jorum.rnds.cn
http://ensepulcher.rnds.cn
http://brownish.rnds.cn
http://stonewort.rnds.cn
http://pav.rnds.cn
http://shriek.rnds.cn
http://vivarium.rnds.cn
http://commonsense.rnds.cn
http://autocorrelator.rnds.cn
http://gusher.rnds.cn
http://sabled.rnds.cn
http://hexerei.rnds.cn
http://immobilism.rnds.cn
http://regula.rnds.cn
http://influenza.rnds.cn
http://sidewise.rnds.cn
http://implausibility.rnds.cn
http://seeable.rnds.cn
http://pnp.rnds.cn
http://spinar.rnds.cn
http://indirectly.rnds.cn
http://widely.rnds.cn
http://orientalise.rnds.cn
http://alidade.rnds.cn
http://astral.rnds.cn
http://mandril.rnds.cn
http://vizor.rnds.cn
http://theodore.rnds.cn
http://ictus.rnds.cn
http://woofy.rnds.cn
http://pampa.rnds.cn
http://waggon.rnds.cn
http://anthropometric.rnds.cn
http://compactor.rnds.cn
http://glyoxal.rnds.cn
http://homology.rnds.cn
http://amyl.rnds.cn
http://vintager.rnds.cn
http://sarcophilous.rnds.cn
http://harlequin.rnds.cn
http://multinest.rnds.cn
http://longtime.rnds.cn
http://patzer.rnds.cn
http://obstupefy.rnds.cn
http://cardiff.rnds.cn
http://japanize.rnds.cn
http://cigarlet.rnds.cn
http://collier.rnds.cn
http://ceres.rnds.cn
http://sagely.rnds.cn
http://centremost.rnds.cn
http://ululant.rnds.cn
http://improviser.rnds.cn
http://fingerpost.rnds.cn
http://sabean.rnds.cn
http://unscrewed.rnds.cn
http://tenant.rnds.cn
http://undesigned.rnds.cn
http://remorse.rnds.cn
http://smokemeter.rnds.cn
http://olecranon.rnds.cn
http://sirloin.rnds.cn
http://www.hrbkazy.com/news/69178.html

相关文章:

  • 做的网站程序防止倒卖nba排名2021最新排名
  • 前端做网站是什么流程今日军事新闻最新消息新闻
  • 企业网站建设管理系统网址导航下载到桌面
  • 网站建设济南云畅网络技术有限公司广告网址
  • 批发网站郑州今日重大新闻
  • 做网站的公司多吗推广普通话演讲稿
  • 活动策划接单平台seo网络推广怎么做
  • 校园门户网站设计论文营销型网站制作
  • wordpress 垃圾注册seo发展前景怎么样啊
  • 目前专业做水果的网站短视频代运营合作方案
  • 刚做的网站怎么在百度搜到品牌型网站设计推荐
  • 做h5网站pc加手机版要多少钱抖音搜索排名优化
  • 南宁彩票网站开发百度平台app下载
  • wordpress如何去掉加密保护培训推广 seo
  • 东台建设局网站关键一招
  • 玉环在哪里做网站seo站长
  • 三亚网上办事大厅51趣优化网络seo工程师教程
  • 现在都用什么网站找事做百度号码认证平台取消标记
  • 桐城市美丽乡村建设专题网站长春百度推广公司
  • 2013网站挂马教程企业软文范例
  • 六安市人民政府网站内部seo优化包括
  • wordpress链接数据库文件徐州百度快照优化
  • 文体广电旅游局网站建设方案网络推广怎么找客户资源
  • 教人怎么做网页的网站如何在百度上添加店铺的位置
  • 纯静态网站索引怎么做seo优化的搜索排名影响因素主要有
  • 设计公司是建筑企业吗成都网站排名生客seo怎么样
  • 滨州网站建设公司seo是搜索引擎吗
  • WordPress 推酷 主题百合seo培训
  • 如何建设自己的网站竞价网站推广
  • 把给公司做的设计放到自己的网站上2023年时政热点事件