|Subject:||Re: [Discuss-gnuradio] Regarding lock protection when setting private variables in gnuradio blocks|
|Date:||Thu, 16 Oct 2014 09:58:44 -0400|
AchilleasIs "forecast()"" need to be protected in such a case as well?just searching on the web i realized that no operation can be assumed atomic, so
I guess every single set_ method (even if it assigns a float/int/short/char) needs to be protected...is this an overkill?
On Wed, Oct 15, 2014 at 11:59 AM, Tom Rondeau <address@hidden> wrote:On Wed, Oct 15, 2014 at 11:49 AM, Achilleas Anastasopoulos <address@hidden> wrote:eg, why is this not used in "add_const_vXX_impl.h.t" ?Is this a standard practice in gnuradio blocks?used in the work function, do we need to protect it to make the whole operation thread safe?If we have a set function in a gr block that sets some private variable that isMy question arose from a comment that Jonathan made on one of the pull requestsin gnuradio (#293).
AchilleasIf it's not atomic, then yes, you really should protect it. All blocks have a mutex called d_setlock you can easily use for this:gr::thread::scoped_lock lock(d_setlock);Tom
|[Prev in Thread]||Current Thread||[Next in Thread]|