aboutsummaryrefslogtreecommitdiffstats
path: root/src/FIRFilter.h
diff options
context:
space:
mode:
authorMatthias P. Braendli (think) <matthias@mpb.li>2013-11-10 21:50:12 +0100
committerMatthias P. Braendli (think) <matthias@mpb.li>2013-11-10 21:50:12 +0100
commit5d965e80be2e6ab62bc82fb2e0d4d472153ad241 (patch)
tree5add36f337b0de524b3d098f0b1fcc8d68aba0d7 /src/FIRFilter.h
parent4f9a01a80570437b86e69eb0542b13df9a20743d (diff)
downloaddabmod-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.h51
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