I'm new in multi-thread programming.
I'm now doing a serial port communication project, and search related codes for reference.
I found a code that someone used scoped_lock
inside lock_guard
as below:
void B(){
boost::mutex::scoped_lock b_lock(b_mutex);
/* do something */
}
void A(){
const std::lock_guard<std::mutex> a_lock(a_mutex);
/* do something */
B();
}
According to this post, I think these two are just to lock mutex. And B()
is called by A()
, so maybe scoped_lock
inside B()
is not needed, and can be removed. Is it right?