diff options
author | andreas128 <Andreas> | 2017-09-12 16:12:49 +0200 |
---|---|---|
committer | andreas128 <Andreas> | 2017-09-12 16:12:49 +0200 |
commit | 7539b330f40275351e6d0aba8f314f5e4a7626e7 (patch) | |
tree | 1aa0f2cd84f2ee0820b1a5b27e792c792759b2bd /src/MemlessPoly.h | |
parent | dd46ed939e56a4e56c3dcec60cce1b93c8786a4a (diff) | |
parent | 0ab36b05bba931c97a0c17cc663e7afb9f89b3cd (diff) | |
download | dabmod-7539b330f40275351e6d0aba8f314f5e4a7626e7.tar.gz dabmod-7539b330f40275351e6d0aba8f314f5e4a7626e7.tar.bz2 dabmod-7539b330f40275351e6d0aba8f314f5e4a7626e7.zip |
Merge branch 'next_memless' of github.com:Opendigitalradio/ODR-DabMod into next_memless
Diffstat (limited to 'src/MemlessPoly.h')
-rw-r--r-- | src/MemlessPoly.h | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/src/MemlessPoly.h b/src/MemlessPoly.h index 4dcd44a..57c0924 100644 --- a/src/MemlessPoly.h +++ b/src/MemlessPoly.h @@ -67,7 +67,51 @@ private: int internal_process(Buffer* const dataIn, Buffer* dataOut); void load_coefficients(const std::string &coefFile); - unsigned int m_num_threads; + struct worker_t { + struct input_data_t { + bool terminate = false; + + const float *coefs_am = nullptr; + const float *coefs_pm = nullptr; + const complexf *in = nullptr; + size_t start = 0; + size_t stop = 0; + complexf *out = nullptr; + }; + + worker_t() {} + worker_t(const worker_t& other) = delete; + worker_t operator=(const worker_t& other) = delete; + worker_t operator=(worker_t&& other) = delete; + + // The move constructor creates a new in_queue and out_queue, + // because ThreadsafeQueue is neither copy- nor move-constructible. + // Not an issue because creating the workers happens at startup, before + // the first work item. + worker_t(worker_t&& other) : + in_queue(), + out_queue(), + thread(std::move(other.thread)) {} + + ~worker_t() { + if (thread.joinable()) { + input_data_t terminate_tag; + terminate_tag.terminate = true; + in_queue.push(terminate_tag); + thread.join(); + } + } + + ThreadsafeQueue<input_data_t> in_queue; + ThreadsafeQueue<int> out_queue; + + std::thread thread; + }; + + std::vector<worker_t> m_workers; + + static void worker_thread(worker_t *workerdata); + std::vector<float> m_coefs_am; // AM/AM coefficients std::vector<float> m_coefs_pm; // AM/PM coefficients std::string m_coefs_file; |