wwc7654321 opened a new pull request #1400: URL: https://github.com/apache/incubator-brpc/pull/1400
The member function "operator=" of std::atomic<bool> is using memory fence "memory_order_seq_cst" (checked msvc142/gcc4.8.2) as default. So the shown error in example 1 will not occur if the type of "ready" is std::atomic<bool> (just the same as it in example 2). Added a comment to clarify the "ready" in example 1 is "bool", to make sure it make sense. std::atomic<bool> 的operator= 重载中,默认使用最严格内存序memory_order_seq_cst (查看msvc142/gcc4.8.2),因此示例1 的问题,在ready是std::atomic<bool>时应该不会出现问题。 如果读者默认示例1和示例2 ready的类型相同(都是std::atomic<bool>),可能存在误解。 因此将示例1中的ready注释为裸bool以确保引发问题 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
