summaryrefslogtreecommitdiffstats
path: root/src/ModPlugin.h
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2018-01-14 07:43:46 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2018-01-14 07:43:46 +0100
commitdb5e90c258f94e65df70830ab1c053debfa15cdb (patch)
tree9ac3a190dec448ae72101dc1a625d7bb3bc0df56 /src/ModPlugin.h
parentd929ecf1e0196161acb5a106761e8fad7040e9d3 (diff)
downloaddabmod-db5e90c258f94e65df70830ab1c053debfa15cdb.tar.gz
dabmod-db5e90c258f94e65df70830ab1c053debfa15cdb.tar.bz2
dabmod-db5e90c258f94e65df70830ab1c053debfa15cdb.zip
Avoid race condition on teardown of pipelined plugins
Diffstat (limited to 'src/ModPlugin.h')
-rw-r--r--src/ModPlugin.h14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/ModPlugin.h b/src/ModPlugin.h
index 5635fca..e9cfa21 100644
--- a/src/ModPlugin.h
+++ b/src/ModPlugin.h
@@ -95,13 +95,6 @@ public:
class PipelinedModCodec : public ModCodec, public ModMetadata
{
public:
- PipelinedModCodec();
- PipelinedModCodec(const PipelinedModCodec&) = delete;
- PipelinedModCodec& operator=(const PipelinedModCodec&) = delete;
- PipelinedModCodec(PipelinedModCodec&&) = delete;
- PipelinedModCodec& operator=(PipelinedModCodec&&) = delete;
- virtual ~PipelinedModCodec();
-
virtual int process(Buffer* const dataIn, Buffer* dataOut) final;
virtual const char* name() = 0;
@@ -111,6 +104,11 @@ protected:
// Once the instance implementing PipelinedModCodec has been constructed,
// it must call start_pipeline_thread()
void start_pipeline_thread(void);
+ // To avoid race conditions on teardown, plugins must call
+ // stop_pipeline_thread in their destructor.
+ void stop_pipeline_thread(void);
+
+ // The real processing must be implemented in internal_process
virtual int internal_process(Buffer* const dataIn, Buffer* dataOut) = 0;
private:
@@ -121,7 +119,7 @@ private:
std::deque<meta_vec_t> m_metadata_fifo;
- std::atomic<bool> m_running;
+ std::atomic<bool> m_running = ATOMIC_VAR_INIT(false);
std::thread m_thread;
void process_thread(void);
};