diff --git a/hecl/include/hecl/ClientProcess.hpp b/hecl/include/hecl/ClientProcess.hpp index a95df203a..729a2c884 100644 --- a/hecl/include/hecl/ClientProcess.hpp +++ b/hecl/include/hecl/ClientProcess.hpp @@ -64,8 +64,8 @@ public: : Transaction(parent, Type::Lambda), m_func(std::move(func)) {} }; private: - std::list> m_pendingQueue; - std::list> m_completedQueue; + std::list> m_pendingQueue; + std::list> m_completedQueue; int m_inProgress = 0; bool m_running = true; @@ -83,12 +83,15 @@ private: public: ClientProcess(int verbosityLevel=1); ~ClientProcess() {shutdown();} - const BufferTransaction* addBufferTransaction(const hecl::ProjectPath& path, void* target, - size_t maxLen, size_t offset); - const CookTransaction* addCookTransaction(const hecl::ProjectPath& path, Database::IDataSpec* spec); - const LambdaTransaction* addLambdaTransaction(std::function&& func); + std::shared_ptr + addBufferTransaction(const hecl::ProjectPath& path, void* target, + size_t maxLen, size_t offset); + std::shared_ptr + addCookTransaction(const hecl::ProjectPath& path, Database::IDataSpec* spec); + std::shared_ptr + addLambdaTransaction(std::function&& func); bool syncCook(const hecl::ProjectPath& path, Database::IDataSpec* spec, BlenderToken& btok); - void swapCompletedQueue(std::list>& queue); + void swapCompletedQueue(std::list>& queue); void waitUntilComplete(); void shutdown(); }; diff --git a/hecl/lib/ClientProcess.cpp b/hecl/lib/ClientProcess.cpp index 318ae650b..17b3d6413 100644 --- a/hecl/lib/ClientProcess.cpp +++ b/hecl/lib/ClientProcess.cpp @@ -70,7 +70,7 @@ void ClientProcess::Worker::proc() } while (m_proc.m_pendingQueue.size()) { - std::unique_ptr trans = std::move(m_proc.m_pendingQueue.front()); + std::shared_ptr trans = std::move(m_proc.m_pendingQueue.front()); ++m_proc.m_inProgress; m_proc.m_pendingQueue.pop_front(); lk.unlock(); @@ -104,32 +104,32 @@ ClientProcess::ClientProcess(int verbosityLevel) } } -const ClientProcess::BufferTransaction* +std::shared_ptr ClientProcess::addBufferTransaction(const ProjectPath& path, void* target, size_t maxLen, size_t offset) { std::unique_lock lk(m_mutex); - BufferTransaction* ret = new BufferTransaction(*this, path, target, maxLen, offset); + auto ret = std::make_shared(*this, path, target, maxLen, offset); m_pendingQueue.emplace_back(ret); m_cv.notify_one(); return ret; } -const ClientProcess::CookTransaction* +std::shared_ptr ClientProcess::addCookTransaction(const hecl::ProjectPath& path, Database::IDataSpec* spec) { std::unique_lock lk(m_mutex); - CookTransaction* ret = new CookTransaction(*this, path, spec); + auto ret = std::make_shared(*this, path, spec); m_pendingQueue.emplace_back(ret); m_cv.notify_one(); return ret; } -const ClientProcess::LambdaTransaction* +std::shared_ptr ClientProcess::addLambdaTransaction(std::function&& func) { std::unique_lock lk(m_mutex); - LambdaTransaction* ret = new LambdaTransaction(*this, std::move(func)); + auto ret = std::make_shared(*this, std::move(func)); m_pendingQueue.emplace_back(ret); m_cv.notify_one(); return ret; @@ -151,7 +151,7 @@ bool ClientProcess::syncCook(const hecl::ProjectPath& path, Database::IDataSpec* return false; } -void ClientProcess::swapCompletedQueue(std::list>& queue) +void ClientProcess::swapCompletedQueue(std::list>& queue) { std::unique_lock lk(m_mutex); queue.swap(m_completedQueue);