aboutsummaryrefslogtreecommitdiffstats
path: root/src/FIRFilter.cpp
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2015-05-30 17:33:13 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2015-05-30 17:33:13 +0200
commitd17c32c28ca3a3810fde93889bfbdc5133ab1bf3 (patch)
tree8d148be15cca5913ddba275ab97876cd60f38563 /src/FIRFilter.cpp
parent43d8e3de1710055e9051ab2696991b9d931283de (diff)
downloaddabmod-d17c32c28ca3a3810fde93889bfbdc5133ab1bf3.tar.gz
dabmod-d17c32c28ca3a3810fde93889bfbdc5133ab1bf3.tar.bz2
dabmod-d17c32c28ca3a3810fde93889bfbdc5133ab1bf3.zip
Use shared_ptr in FIRFilter
Diffstat (limited to 'src/FIRFilter.cpp')
-rw-r--r--src/FIRFilter.cpp21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/FIRFilter.cpp b/src/FIRFilter.cpp
index 805c6d2..b1ce618 100644
--- a/src/FIRFilter.cpp
+++ b/src/FIRFilter.cpp
@@ -36,6 +36,8 @@
#include <iostream>
#include <fstream>
+#include <boost/make_shared.hpp>
+
#ifdef __AVX__
# include <immintrin.h>
#else
@@ -58,11 +60,10 @@ void FIRFilterWorker::process(struct FIRFilterWorkerData *fwd)
// the incoming buffer
while(running) {
- Buffer* dataIn;
+ boost::shared_ptr<Buffer> dataIn;
fwd->input_queue.wait_and_pop(dataIn);
- Buffer* dataOut;
- dataOut = new Buffer();
+ boost::shared_ptr<Buffer> dataOut = boost::make_shared<Buffer>();
dataOut->setLength(dataIn->getLength());
PDEBUG("FIRFilterWorker: dataIn->getLength() %zu\n", dataIn->getLength());
@@ -91,7 +92,7 @@ void FIRFilterWorker::process(struct FIRFilterWorkerData *fwd)
fprintf(stderr, "FIRFilterWorker: out not aligned %p ", out);
throw std::runtime_error("FIRFilterWorker: out not aligned");
}
-
+
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &time_start);
__m256 AVXout;
@@ -141,7 +142,7 @@ void FIRFilterWorker::process(struct FIRFilterWorkerData *fwd)
fprintf(stderr, "FIRFilterWorker: out not aligned %p ", out);
throw std::runtime_error("FIRFilterWorker: out not aligned");
}
-
+
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &time_start);
__m128 SSEout;
@@ -290,11 +291,10 @@ void FIRFilterWorker::process(struct FIRFilterWorkerData *fwd)
}
}
#endif
-
+
calculationTime += (time_end.tv_sec - time_start.tv_sec) * 1000000000L +
time_end.tv_nsec - time_start.tv_nsec;
fwd->output_queue.push(dataOut);
- delete dataIn;
}
}
@@ -393,17 +393,16 @@ int FIRFilter::process(Buffer* const dataIn, Buffer* dataOut)
// This thread creates the dataIn buffer, and deletes
// the outgoing buffer
- Buffer* inbuffer = new Buffer(dataIn->getLength(), dataIn->getData());
+ boost::shared_ptr<Buffer> inbuffer =
+ boost::make_shared<Buffer>(dataIn->getLength(), dataIn->getData());
firwd.input_queue.push(inbuffer);
if (number_of_runs > 2) {
- Buffer* outbuffer;
+ boost::shared_ptr<Buffer> outbuffer;
firwd.output_queue.wait_and_pop(outbuffer);
dataOut->setData(outbuffer->getData(), outbuffer->getLength());
-
- delete outbuffer;
}
else {
dataOut->setLength(dataIn->getLength());