summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gr-blocks/lib/stream_to_tagged_stream_impl.cc7
-rw-r--r--gr-blocks/lib/stream_to_tagged_stream_impl.h2
-rw-r--r--gr-fft/lib/fft.cc32
3 files changed, 41 insertions, 0 deletions
diff --git a/gr-blocks/lib/stream_to_tagged_stream_impl.cc b/gr-blocks/lib/stream_to_tagged_stream_impl.cc
index 58e1a9c5b0..f0de33a16f 100644
--- a/gr-blocks/lib/stream_to_tagged_stream_impl.cc
+++ b/gr-blocks/lib/stream_to_tagged_stream_impl.cc
@@ -84,6 +84,13 @@ namespace gr {
return noutput_items;
}
+ bool
+ stream_to_tagged_stream_impl::start()
+ {
+ d_next_tag_pos = 0;
+ return true;
+ }
+
} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/stream_to_tagged_stream_impl.h b/gr-blocks/lib/stream_to_tagged_stream_impl.h
index dc9c117765..586bd202fa 100644
--- a/gr-blocks/lib/stream_to_tagged_stream_impl.h
+++ b/gr-blocks/lib/stream_to_tagged_stream_impl.h
@@ -46,6 +46,8 @@ namespace gr {
int work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
+
+ bool start();
};
} // namespace blocks
diff --git a/gr-fft/lib/fft.cc b/gr-fft/lib/fft.cc
index 5af77d97eb..ef81583187 100644
--- a/gr-fft/lib/fft.cc
+++ b/gr-fft/lib/fft.cc
@@ -46,10 +46,12 @@ static int my_fftw_read_char(void *f) { return fgetc((FILE *) f); }
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
+#include <boost/interprocess/sync/file_lock.hpp>
namespace fs = boost::filesystem;
namespace gr {
namespace fft {
+ static boost::mutex wisdom_thread_mutex;
gr_complex *
malloc_complex(int size)
@@ -92,6 +94,30 @@ namespace gr {
}
static void
+ lock_wisdom()
+ {
+ const std::string wisdom_lock_file = wisdom_filename() + ".lock";
+ int fd = open(wisdom_lock_file.c_str(),
+ O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK,
+ 0666);
+ if (fd < 0){
+ throw std::exception();
+ }
+ boost::interprocess::file_lock wisdom_lock(wisdom_lock_file.c_str());
+ wisdom_lock.lock();
+ wisdom_thread_mutex.lock();
+ }
+
+ static void
+ unlock_wisdom()
+ {
+ const std::string wisdom_lock_file = wisdom_filename() + ".lock";
+ boost::interprocess::file_lock wisdom_lock(wisdom_lock_file.c_str());
+ wisdom_lock.unlock();
+ wisdom_thread_mutex.unlock();
+ }
+
+ static void
import_wisdom()
{
const std::string filename = wisdom_filename ();
@@ -162,6 +188,7 @@ namespace gr {
d_nthreads = nthreads;
config_threading(nthreads);
+ lock_wisdom();
import_wisdom(); // load prior wisdom from disk
d_plan = fftwf_plan_dft_1d (fft_size,
@@ -175,6 +202,7 @@ namespace gr {
throw std::runtime_error ("fftwf_plan_dft_1d failed");
}
export_wisdom(); // store new wisdom to disk
+ unlock_wisdom();
}
fft_complex::~fft_complex()
@@ -233,6 +261,7 @@ namespace gr {
d_nthreads = nthreads;
config_threading(nthreads);
+ lock_wisdom();
import_wisdom(); // load prior wisdom from disk
d_plan = fftwf_plan_dft_r2c_1d (fft_size,
@@ -245,6 +274,7 @@ namespace gr {
throw std::runtime_error ("fftwf_plan_dft_r2c_1d failed");
}
export_wisdom(); // store new wisdom to disk
+ unlock_wisdom();
}
fft_real_fwd::~fft_real_fwd()
@@ -303,6 +333,7 @@ namespace gr {
d_nthreads = nthreads;
config_threading(nthreads);
+ lock_wisdom();
import_wisdom(); // load prior wisdom from disk
// FIXME If there's ever a chance that the planning functions
@@ -318,6 +349,7 @@ namespace gr {
throw std::runtime_error ("fftwf_plan_dft_c2r_1d failed");
}
export_wisdom (); // store new wisdom to disk
+ unlock_wisdom();
}
fft_real_rev::~fft_real_rev ()