On Tue, Jul 2, 2013 at 4:06 PM, Monahan-Mitchell, Tim < tmona...@qti.qualcomm.com> wrote:
> I see different use cases of this in the gnuradio tree, like: > > gr::thread::scoped_lock guard(d_mutex); > > gr::thread::scoped_lock l(d_mutex); > > gr::thread::scoped_lock lock(d_setlock); > > As well as variances of whether the mutex variable is declared in a header > file... > > Could someone lend some kind words on what is recommended (at least for GR > 3.7)? > There is really nothing special or unique going on here. A scoped lock grabs the associated mutex during its scope lifetime. The above three are just using different names for the local variable instance of the the lock. The associated mutex is usually a (private) member viable 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 on 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. -- Johnathan Corgan Corgan Labs - SDR Training and Development Services http://corganlabs.com
_______________________________________________ Discuss-gnuradio mailing list Discuss-gnuradio@gnu.org https://lists.gnu.org/mailman/listinfo/discuss-gnuradio