diff options
author | Johnathan Corgan <johnathan@corganlabs.com> | 2017-06-22 17:12:05 -0700 |
---|---|---|
committer | Johnathan Corgan <johnathan@corganlabs.com> | 2017-06-22 17:12:05 -0700 |
commit | b63e8cf03236257730680adfd75378daf3f5c153 (patch) | |
tree | 0cb65a8bc2e2d8e8ed9ea6c880f991c4eed4e299 /gr-fft | |
parent | e4783ab3f1541d8ba32c0269eb30b7c06d0888c2 (diff) | |
parent | 1d537a26b27b9d3ce6a3affc6ea500a9efc5a867 (diff) |
Merge branch 'next' into python3
Conflicts:
gnuradio-runtime/python/gnuradio/gr/tag_utils.py
Diffstat (limited to 'gr-fft')
-rw-r--r-- | gr-fft/lib/fft.cc | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/gr-fft/lib/fft.cc b/gr-fft/lib/fft.cc index ef81583187..3b6d05c383 100644 --- a/gr-fft/lib/fft.cc +++ b/gr-fft/lib/fft.cc @@ -36,6 +36,10 @@ static int my_fftw_read_char(void *f) { return fgetc((FILE *) f); } #define fftw_import_wisdom_from_file(f) fftw_import_wisdom(my_fftw_read_char, (void*) (f)) #define fftwf_import_wisdom_from_file(f) fftwf_import_wisdom(my_fftw_read_char, (void*) (f)) #define fftwl_import_wisdom_from_file(f) fftwl_import_wisdom(my_fftw_read_char, (void*) (f)) +#include <fcntl.h> +#include <io.h> +#define O_NOCTTY 0 +#define O_NONBLOCK 0 #endif //_MSC_VER #include <stdlib.h> @@ -52,6 +56,7 @@ namespace fs = boost::filesystem; namespace gr { namespace fft { static boost::mutex wisdom_thread_mutex; + boost::interprocess::file_lock wisdom_lock; gr_complex * malloc_complex(int size) @@ -96,23 +101,13 @@ 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(); + wisdom_thread_mutex.lock(); + wisdom_lock.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(); } @@ -168,6 +163,15 @@ namespace gr { { // Hold global mutex during plan construction and destruction. planner::scoped_lock lock(planner::mutex()); + 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(); + } + close(fd); + wisdom_lock = boost::interprocess::file_lock(wisdom_lock_file.c_str()); assert (sizeof (fftwf_complex) == sizeof (gr_complex)); |