Worker thread per plugin instance.

This commit is contained in:
Robin E. R. Davies
2025-07-22 16:02:37 -04:00
parent 7ffbee16cf
commit ea134b46a8
8 changed files with 56 additions and 29 deletions
+8 -6
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2022 Robin Davies
// Copyright (c) 2025 Robin Davies
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
@@ -32,6 +32,7 @@
#include "lv2/atom/atom.h"
#include "lv2/worker/worker.h"
#include "condition_variable"
#include <atomic>
#include <map>
#include <string>
@@ -51,10 +52,12 @@ namespace pipedal {
HostWorkerThread();
~HostWorkerThread();
bool StartThread();
void Close();
bool Closed() const { return closed || pThread == nullptr; }
LV2_Worker_Status ScheduleWork(Worker*worker, size_t size, const void*data);
private:
bool closed = false;
std::atomic<bool> closed = false;
std::unique_ptr<std::thread> pThread;
void ThreadProc() noexcept;
@@ -64,8 +67,6 @@ namespace pipedal {
std::vector<uint8_t> dataBuffer;
};
class Worker {
@@ -75,8 +76,8 @@ namespace pipedal {
LilvInstance*lilvInstance;
const LV2_Worker_Interface*workerInterface;
bool closed = false;
bool exiting = false;
std::atomic<bool> closed = false;
std::atomic<bool> exiting = false;
RingBuffer<true,false> responseRingBuffer;
std::vector<uint8_t> responseBuffer;
@@ -94,6 +95,7 @@ namespace pipedal {
public:
Worker(const std::shared_ptr<HostWorkerThread>& pHostWorker,LilvInstance *instance, const LV2_Worker_Interface *iface);
~Worker();
void Close();
LV2_Worker_Status ScheduleWork(