Cplusplus-Concurrency-In-Practice
Cplusplus-Concurrency-In-Practice copied to clipboard
A Detailed Cplusplus Concurrency Tutorial 《C++ 并发编程指南》
there are so many pull requests, please deal with them , tks!
修复了失效的链接
1. remove useless header file. `#include ` 2. use namespace std in .cpp file 3. update source code format in the .md file: add code language declaration to tell markdown...
from http://en.cppreference.com/
1. use stock_position instead read/write_postition 2. use random time simulate produce/consume time
调整格式,为1.1节增加md文件,并在readme中增加链接
在move语义的那个例子中,给传递给process_value的参数i进行右值化处理,而使得process_value可以调用右值的版本。当然这里如果参数i是左值的,std::forward是不起任何作用的。
Hi, 我大概看了一下内存模型部分,整体来说写得不错,精神可佳,貌似你大多数部分是翻译的那本concurrency in action?有个地方貌似不太准确,请你参考。 > 例如,如果两个变量读写互不相关,编译器有可能将读操作提前(暂且称为预读prefetch 吧),或者尽可能延迟写操作,假设如下面的代码段:.... 首先这里不能称为预读,这里编译器的优化其实是instruction reorder,是为了充分利用cpu的流水线结构,而将读写不相关的操作放到一起,这样cpu在等待一个数据从内存读过来(数千cpu周期)的时候,同时还能干别的,而不是干等着。预读是硬件的,和编译器没有太大关系。 其次,下面的这个例子。。。请问你是不是没有亲自编译看看?按照你写的这种reorder,结果都变了,这不可能的。。。