From d8e73d63c0af6ba6810319d866cab07b332d0e42 Mon Sep 17 00:00:00 2001
From: Tom Rondeau <trondeau@vt.edu>
Date: Tue, 26 Feb 2013 12:00:47 -0500
Subject: core: adding a mutex as a protected member of gr_block for use in
 protecting set and work function access to variables.

This is used in gr-analog's noise_source and gr-filter's fir_filter_XXX since these two cause particular problems (in next's channel model). This shows the use of the mutex for general protection when needed.
---
 gr-analog/lib/noise_source_X_impl.cc.t | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

(limited to 'gr-analog/lib/noise_source_X_impl.cc.t')

diff --git a/gr-analog/lib/noise_source_X_impl.cc.t b/gr-analog/lib/noise_source_X_impl.cc.t
index 35dda9c5d4..40e2517d2e 100644
--- a/gr-analog/lib/noise_source_X_impl.cc.t
+++ b/gr-analog/lib/noise_source_X_impl.cc.t
@@ -54,11 +54,27 @@ namespace gr {
     {
     }
 
+    void
+    @IMPL_NAME@::set_type(noise_type_t type)
+    {
+      gruel::scoped_lock l(d_setlock);
+      d_type = type;
+    }
+
+    void
+    @IMPL_NAME@::set_amplitude(float ampl)
+    {
+      gruel::scoped_lock l(d_setlock);
+      d_ampl = ampl;
+    }
+
     int
     @IMPL_NAME@::work(int noutput_items,
 		      gr_vector_const_void_star &input_items,
 		      gr_vector_void_star &output_items)
     {
+      gruel::scoped_lock l(d_setlock);
+
       @TYPE@ *out = (@TYPE@*)output_items[0];
 
       switch(d_type) {
-- 
cgit v1.2.3