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

阳山网站建设php网站开发哪个培训学校好

阳山网站建设,php网站开发哪个培训学校好,c 语言Vs做网站接口,wordpress国内打开速度慢​std::jthread是C20新引入的线程类#xff0c;与 std::thread 类似#xff0c;或者说#xff0c;jthread是对thread进一步的封装#xff0c;功能更强大​。 ​std::jthread的​j实际上是​joining的缩写​#xff0c;​众所周知#xff0c;std::thread在其生命周期结束…​std::jthread是C20新引入的线程类与 std::thread 类似或者说jthread是对thread进一步的封装功能更强大​。 ​std::jthread的​j实际上是​joining的缩写​​众所周知std::thread在其生命周期结束时调用join()(让主线程等待该子线程完成然后主线程再继续执行对于不会停止的线程不要使用join()防止阻塞其他线程)或调用detach()(调用detach()进行线程分离使其不影响其他线程运行比如一个线程中无限循环执行的场景下需要detach()。如果join()和detach()都没有被调用析构函数​将立即导致程序异常终止。C20引入的std::jthread得以解决这个问题std::jthread对象被析构时会自动调用join()等待执行流结束。​ ​此外​std::jthread​​支持外部请求中止操作​调用join()后可能需要等待很长时间甚至是永远等待。std::jthread除了提供std::stop_token能够主动取消或停止正在执行的线程还增加了std::stop_callback允许在停止线程操作时调用一组回调函数。​ 来看看cpprefercence关于std::jthread::~jthread的解释 std::jthread::~jthread Destroys the ​​jthread​​ object. If ​​*​this​ has an associated thread (​joinable​()​ ​​ ​true​​), calls request_stop() and then join(). Notes The request_stop() has no effect if the ​​jthread​​ was previously requested to stop. A ​​jthread​​ object does not have an associated thread after it was default-constructedit was moved fromjoin() has been calleddetach() has been calledIf join() throws an exception (e.g. because deadlock is detected),​​ std::terminate()​​ may be called. 关于​std::jthread::join​的作用​阻塞当前线程直至 ​*​this 所标识的线程结束其执行。​ 看例程 #include iostream #include thread #include chronovoid foo() {// 模拟耗费大量资源的操作std::this_thread::sleep_for(std::chrono::seconds(1)); }void bar() {// 模拟耗费大量资源的操作std::this_thread::sleep_for(std::chrono::seconds(1)); }int main() {std::cout starting first helper...\n;std::jthread helper1(foo);std::cout starting second helper...\n;std::jthread helper2(bar);std::cout waiting for helpers to finish... std::endl;helper1.join();helper2.join();std::cout done!\n; } 输出结果如下 starting first helper... starting second helper... waiting for helpers to finish... done! ​std::jthread::joinable​主要是用来检查 std::jthread 对象是否标识活跃的执行线程直接看cpprefercence相关例程 #include iostream #include thread #include chronovoid foo() {std::this_thread::sleep_for(std::chrono::seconds(1)); }int main() {std::jthread t;std::cout before starting, joinable: std::boolalpha t.joinable() \n;t std::thread(foo);std::cout after starting, joinable: t.joinable() \n;t.join();std::cout after joining, joinable: t.joinable() \n; } 输出结果如下 before starting, joinable: false after starting, joinable: true after joining, joinable: false 可知如果 jthread 对象标识活跃的执行线程则为 true 否则为 false 。
http://www.yutouwan.com/news/72906/

相关文章:

  • 福安网站开发化妆品公司网站源码
  • 织梦网站档目管理空白网页程序开发基础知识
  • 做养生产品哪个网站好wordpress三栏模板
  • 网站搜索怎么做的龙岗网页设计
  • 品质培训的网站建设jsp做网站步骤
  • 建立网站小程序国内做的比较好的协会网站
  • 建设网站的好公司做阿里巴巴网站 店铺装修免费吗
  • 网站备案负责人照片公司做网站推广的价格
  • 影视视频网站怎么做浏览器网址导航网
  • 乐云seo网站建设性价比高腾讯邮箱官网
  • 网站开发语言net网站年龄和域名年龄
  • 网站后台管理怎么进短网址生成源码
  • 怎样做视频上网站赚钱建设银行网站图片大全
  • 对整个网站做词频分析如何更改网站域名
  • 商务网站开发步骤网站出现的的问题
  • 网站域名做链接怎么做网站升级维护要多久
  • 天津公司网站建设费湖南做网站找谁
  • 门户网站制作定制国外公司在国内建网站
  • 石景山网站制作莱芜都市网直播
  • phpcms 外贸网站模板建站之星管理中心
  • 网站布局策划10m带宽做下载网站
  • 怎么直接做免费网站吗互联网是什么
  • 网站开发 教程制作手工作品
  • 珠海市网站建设哪家好建网站的步骤
  • 男女做那个的网站是什么wordpress header在哪
  • 网站建设的公司工作室亚马逊网站怎么做
  • 北京做网站哪个好自己创建网站要钱吗
  • 做海报素材的网站会刊彩页设计
  • 网站备案需要钱吗wordpress一小时建站
  • 门户网站是啥seo主要做哪些工作