We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
web 位置
原文:
std::mutex 是 C++11 中最基本的 mutex 类,通过实例化 std::mutex 可以创建互斥量, 而通过其成员函数 lock() 可以进行上锁,unlock() 可以进行解锁。 但是在实际编写代码的过程中,最好不去直接调用成员函数, 因为调用成员函数就需要在每个临界区的出口处调用 unlock(),当然,还包括异常。 这时候 C++11 还为互斥量提供了一个 RAII 语法的模板类 std::lock_guard。
RAII(Resource Acquisition Is Initialization)并不是一种语法,而是一种 C++ 编程技术(或者说是一种设计方式)。此处存在误导,应该将“RAII 语法”改为“RAII 机制”或者“RAII 模式”。
也就是:“C++11 还为互斥量提供了一个 RAII 机制的模板类 std::lock_guard”。
std::lock_guard
如有更好的措辞可再提,不过至少“RAII 语法”完全不正确。
The text was updated successfully, but these errors were encountered:
Thanks and PR welcome
Sorry, something went wrong.
Successfully merging a pull request may close this issue.
web 位置
原文:
RAII(Resource Acquisition Is Initialization)并不是一种语法,而是一种 C++ 编程技术(或者说是一种设计方式)。此处存在误导,应该将“RAII 语法”改为“RAII 机制”或者“RAII 模式”。
也就是:“C++11 还为互斥量提供了一个 RAII 机制的模板类
std::lock_guard
”。如有更好的措辞可再提,不过至少“RAII 语法”完全不正确。
The text was updated successfully, but these errors were encountered: