diff options
author | Matthias P. Braendli (think) <matthias@mpb.li> | 2013-11-10 21:50:12 +0100 |
---|---|---|
committer | Matthias P. Braendli (think) <matthias@mpb.li> | 2013-11-10 21:50:12 +0100 |
commit | 5d965e80be2e6ab62bc82fb2e0d4d472153ad241 (patch) | |
tree | 5add36f337b0de524b3d098f0b1fcc8d68aba0d7 /src/FIRFilter.h | |
parent | 4f9a01a80570437b86e69eb0542b13df9a20743d (diff) | |
download | dabmod-5d965e80be2e6ab62bc82fb2e0d4d472153ad241.tar.gz dabmod-5d965e80be2e6ab62bc82fb2e0d4d472153ad241.tar.bz2 dabmod-5d965e80be2e6ab62bc82fb2e0d4d472153ad241.zip |
crc-dabmod: add ZeroMQ input module
Diffstat (limited to 'src/FIRFilter.h')
-rw-r--r-- | src/FIRFilter.h | 51 |
1 files changed, 2 insertions, 49 deletions
diff --git a/src/FIRFilter.h b/src/FIRFilter.h index b9abb3e..8acd444 100644 --- a/src/FIRFilter.h +++ b/src/FIRFilter.h @@ -30,11 +30,12 @@ #endif #include <boost/thread.hpp> -#include <queue> +#include "ThreadsafeQueue.h" #include "RemoteControl.h" #include "ModCodec.h" #include "PcDebug.h" +#include "ThreadsafeQueue.h" #include <sys/types.h> #include <complex> @@ -47,54 +48,6 @@ typedef std::complex<float> complexf; -template<typename T> -class ThreadsafeQueue -{ -private: - std::queue<T> the_queue; - mutable boost::mutex the_mutex; - boost::condition_variable the_condition_variable; -public: - void push(T const& val) - { - boost::mutex::scoped_lock lock(the_mutex); - the_queue.push(val); - lock.unlock(); - the_condition_variable.notify_one(); - } - - bool empty() const - { - boost::mutex::scoped_lock lock(the_mutex); - return the_queue.empty(); - } - - bool try_pop(T& popped_value) - { - boost::mutex::scoped_lock lock(the_mutex); - if(the_queue.empty()) - { - return false; - } - - popped_value = the_queue.front(); - the_queue.pop(); - return true; - } - - void wait_and_pop(T& popped_value) - { - boost::mutex::scoped_lock lock(the_mutex); - while(the_queue.empty()) - { - the_condition_variable.wait(lock); - } - - popped_value = the_queue.front(); - the_queue.pop(); - } -}; - struct FIRFilterWorkerData { /* Thread-safe queues to give data to and get data from * the worker |