export gri_fft planning mutex
authoreb <eb@221aa14e-8319-0410-a670-987f0aec2ac5>
Wed, 3 Sep 2008 17:00:14 +0000 (17:00 +0000)
committereb <eb@221aa14e-8319-0410-a670-987f0aec2ac5>
Wed, 3 Sep 2008 17:00:14 +0000 (17:00 +0000)
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@9493 221aa14e-8319-0410-a670-987f0aec2ac5

gnuradio-core/src/lib/general/gri_fft.cc
gnuradio-core/src/lib/general/gri_fft.h

index 509420d8a85e8c7f4505b110994cb90261a28030..b7245a3895ca6554837be5865432be82cf172048 100644 (file)
 #include <stdio.h>
 #include <cassert>
 #include <stdexcept>
-#include <boost/thread.hpp>
 
-typedef boost::mutex::scoped_lock scoped_lock;
-static boost::mutex  s_planning_mutex;
 
+boost::mutex &
+gri_fft_planner::mutex()
+{
+  static boost::mutex  s_planning_mutex;
+
+  return s_planning_mutex;
+}
 
 static char *
 wisdom_filename ()
@@ -86,7 +90,7 @@ gri_fftw_export_wisdom ()
 gri_fft_complex::gri_fft_complex (int fft_size, bool forward)
 {
   // Hold global mutex during plan construction and destruction.
-  scoped_lock  lock(s_planning_mutex);
+  gri_fft_planner::scoped_lock lock(gri_fft_planner::mutex());
 
   assert (sizeof (fftwf_complex) == sizeof (gr_complex));
   
@@ -121,7 +125,7 @@ gri_fft_complex::gri_fft_complex (int fft_size, bool forward)
 gri_fft_complex::~gri_fft_complex ()
 {
   // Hold global mutex during plan construction and destruction.
-  scoped_lock  lock(s_planning_mutex);
+  gri_fft_planner::scoped_lock lock(gri_fft_planner::mutex());
 
   fftwf_destroy_plan ((fftwf_plan) d_plan);
   fftwf_free (d_inbuf);
@@ -139,7 +143,7 @@ gri_fft_complex::execute ()
 gri_fft_real_fwd::gri_fft_real_fwd (int fft_size)
 {
   // Hold global mutex during plan construction and destruction.
-  scoped_lock  lock(s_planning_mutex);
+  gri_fft_planner::scoped_lock lock(gri_fft_planner::mutex());
 
   assert (sizeof (fftwf_complex) == sizeof (gr_complex));
   
@@ -173,7 +177,7 @@ gri_fft_real_fwd::gri_fft_real_fwd (int fft_size)
 gri_fft_real_fwd::~gri_fft_real_fwd ()
 {
   // Hold global mutex during plan construction and destruction.
-  scoped_lock  lock(s_planning_mutex);
+  gri_fft_planner::scoped_lock lock(gri_fft_planner::mutex());
 
   fftwf_destroy_plan ((fftwf_plan) d_plan);
   fftwf_free (d_inbuf);
index 7bfdce0b92b5b1172803978d6cf19b855d57dab5..720084eb604217653e7c85d7b5a69708563efbe1 100644 (file)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2003 Free Software Foundation, Inc.
+ * Copyright 2003,2008 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
  */
 
 #include <gr_complex.h>
+#include <boost/thread.hpp>
+
+/*!
+ * \brief Export reference to planner mutex for those apps that
+ * want to use FFTW w/o using the gri_fftw* classes.
+ */
+class gri_fft_planner {
+public:
+  typedef boost::mutex::scoped_lock scoped_lock;
+  /*!
+   * Return reference to planner mutex
+   */
+  static boost::mutex &mutex();
+};
 
 /*!
  * \brief FFT: complex in, complex out
  * \ingroup dft
  */
-
 class gri_fft_complex {
   int        d_fft_size;
   gr_complex *d_inbuf;