Ø  The associated mutex is usually a (private) member variable of a class, and 
is used as a synchronization object by different class methods.  As a member 
variable, you have a choice to name it whatever you want.  If the mutex is the 
only one in the class, we usually call it d_mutex.  If there is more than one 
mutex in the class, then we give it a unique name.


Ø  If you're writing your own code as a class, making the mutex a member 
variable and calling it d_mutex, and calling the local scoped lock object 
'guard', is probably the most descriptive, but again, it's up to you.

OK, that helps, thanks.

One additional question - looking file_meta_source_impl.cc, it uses 'd_mutex' 
in all cases; in most places in the file, the object is called 
'guard(d_mutex)'. But in one place the object is called 'lock(d_mutex)'... Is 
that a mistake?

I got concerned when I read some about this on the net, saying that it is easy 
to forget that a local object will get destroyed when the scope that created it 
closes. Hence the need for d_mutex to get defined as a private class member 
(but it compiles fine if that step is forgotten).

Tim
_______________________________________________
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio

Reply via email to