acquire()的描述为 Atomically decrements the internal counter by 1 if it is greater than 0; otherwise blocks until it is greater than 0 and can successfully decrement the internal counter.
并不是acquire()即 P 操作,会在信号量值不小于 0 时将信号量减 1
应该修改acquire()即 P 操作,会在信号量值为不小于等于0 或者 大于0时将信号量减 1
P20 ,The act of calling join() also cleans up any storage associated with the thread, so the std::thread object is no longer associated with the now-finished thread; it isn’t associated with any thread. 这句话我没太懂?
P22 The copy constructor and copy-assignment operators are marked =delete to ensure
that they’re not automatically provided by the compiler. Copying or assigning such an
object would be dangerous, because it might then outlive the scope of the thread it was
joining. By declaring them as deleted, any attempt to copy a thread_guard object will
generate a compilation error. 如果不将copy-assignment 定为 deleted的话,为什么是危险的呀?能否举一个例子?
《C++ Concurrency in Action》Second Edition,Chapter 3.3.1 节最后部分关于 static变量 初始化的描述,仅指的是 static local variable 的初始化自 C++11 起是线程安全的,对于 static non-local variable 是未提及的,即对于具有静态存储期的非局部变量,如 global variable 和类的 static data member ,它们的初始化会作为程序启动的一部分在 main 函数的执行之前进行:简单的类型会在编译期进行初始化,如 constexpr 类型,复杂的类型则需要在运行期初始化,如 复杂的类对象(初始化时需要调用构造函数)。在程序结束时它们才会被销毁。因为 static non-local variable 的初始化会作为程序启动的一部分在 main 函数的执行之前进行,所以其初始化不存在多个线程竞争初始化的问题,但是却存在异常安全和 initialization order 的问题。详见 Static local variable and Global variable 。
即文中应该写为: “C++11规定static局部变量的初始化……”
Issue2
class A 的 copy assignment operator 漏写了字符 = ,即应该是: A& operator=(const A&) = delete;