我有以下代码。我想知道scoped锁是否在函数“do_something”的开头被锁定了?非常感谢!
class Test {
public:
void do_something () {
std::cout << "anything printable" << std::endl;
// do something else
// Has mu_ got locked here?
...
std::lock_guard<std::mutex> l(mu_);
// something only I can do
...
return;
}
private:
std::mutex mu_;
}