Skip to Content
C++程序设计语言(第4部分:标准库)(原书第4版)
book

C++程序设计语言(第4部分:标准库)(原书第4版)

by 本贾尼 斯特劳斯特鲁普
August 2021
Intermediate to advanced
450 pages
6h 57m
Chinese
Pearson
Content preview from C++程序设计语言(第4部分:标准库)(原书第4版)

42.5 建议

[1]thread是系统线程的类型安全的接口;42.2节。

[2]不要销毁正在运行的thread;42.2.2节。

[3]用join()等待thread结束;42.2.4节。

[4]考虑使用guarded_thread为thread提供RAII;42.2.4节。

[5]除非不得已,否则不要detach()一个thread;42.2.4节。

[6]用lock_guard或unique_lock管理互斥量;42.3.1.4节。

[7]用lock()获取多重锁;42.3.2节。

[8]用condition_variable管理thread间通信;42.3.4节。

[9]从并发执行任务的角度思考,而非直接从thread角度思考;42.4节。

[10]重视简洁性;42.4节。

[11]用promise返回结果,从future获取结果;42.4.1节。

[12]不要对一个promise两次执行set_value()或set_exception();42.4.2节。

[13]用packaged_task管理任务抛出的异常以及安排返回值;42.4.3节。

[14]用packaged_task和future表达对外部服务的请求以及等待其应答;42.4.3节。

[15]不要从一个future两次使用get();42.4.4节。

[16]用async()启动简单任务;见42.4.6节。

[17]选择好的并发粒度很困难:依赖实验和测量做出选择;见42.4.7节。

[18]尽量将并发隐藏在并行算法接口之后;见42.4.7节。

[19]并行算法在语义上可能与解决同一问题的串行解决方案不同(如pfind_all()对find());见42.4.7节。

[20]有时,串行解决方案比并行版本简单且快速;见42.4.7节。 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

算法精讲视频课程:24篇系列讲座

算法精讲视频课程:24篇系列讲座

罗伯特·塞奇威克, 凯文·韦恩(Kevin Wayne)
可编程网络自动化

可编程网络自动化

Jason Edelman, Scott S. Lowe, Matt Oswalt
C语言核心技术(原书第2版)

C语言核心技术(原书第2版)

Peter Prinz, Tony Crawford
Go程序设计语言

Go程序设计语言

艾伦A. A.多诺万, 布莱恩W. 柯尼汉

Publisher Resources

ISBN: 9787111544395