discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Discuss-gnuradio] Proper use of scoped_lock in out-of-tree module?


From: Johnathan Corgan
Subject: Re: [Discuss-gnuradio] Proper use of scoped_lock in out-of-tree module?
Date: Mon, 08 Jul 2013 08:58:19 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130623 Thunderbird/17.0.7

On 07/08/2013 08:44 AM, Monahan-Mitchell, Tim wrote:

> In my GR 3.6.4.2-based OOT module, I placed a line like this where I wanted 
> exclusivity from other entry points (copied from looking at examples in the 
> gnuradio tree):
> 
> gruel::scoped_lock l(d_setlock);
> 
> ... and did nothing else (no #include, no declaration of d_setlock anywhere). 
> I used gr_modtool to generate the skeleton files. It compiled and ran without 
> complaints (on VMware x86 and ARM target). As to whether it actually did what 
> it was supposed to do, I don't know. I have since seen occurrences of 
> "#include<gruel/attributes.h>" in the template header files, but I was dumb 
> and happy at this point, so no worries. (You should have deduced by now that 
> I don't use C++ much...)
> 
> While stepping up to GR 3.7, one of the things to change was that include 
> line, which made me investigate more, and I read this article: 
> http://jek-thoughts.blogspot.com/2010/06/pitfalls-of-scoped-lock.html . That 
> caused me to start this thread.
> 
> So I have higher confidence now that I'm using the scope lock tool correctly, 
> thanks again.

Ahh, you sort of got lucky.  All blocks have a protected mutex variable
called 'd_setlock' (it comes from gr::block, see
include/gnuradio/block.h), and was put there explicitly for users to
have a ready made mutex to do what you're doing.

So yes, you're doing it right, but the mutex does need to get declared.
 It's just that in your particular case, it was done for you already in
a parent class.

-- 
Johnathan Corgan
Corgan Labs - SDR Training and Development Services
http://corganlabs.com

Attachment: 0x671DA2F7.asc
Description: application/pgp-keys

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]