services: do not use _threads as class member 94/311194/2
authorInki Dae <inki.dae@samsung.com>
Thu, 16 May 2024 02:29:47 +0000 (11:29 +0900)
committerInki Dae <inki.dae@samsung.com>
Thu, 16 May 2024 05:54:02 +0000 (14:54 +0900)
Do not use _threads as class member. It's enogh with local threads handles
so drop _threads from class member and use local one instead.

Change-Id: Id99b0b5d51e5f02ff09aae1647be7e2645491e37
Signed-off-by: Inki Dae <inki.dae@samsung.com>
services/task_manager/include/TaskManager.h
services/task_manager/src/TaskManager.cpp

index f621954217588993c4b1176cbbdc7212e2435747..2450b76a3a402c2cb229dc73e1b75cc2c28b634d 100644 (file)
@@ -34,7 +34,6 @@ class TaskManager
 private:
        std::vector<std::shared_ptr<BaseDataType> > _inputs;
        std::vector<std::shared_ptr<INode> > _nodes;
-       std::vector<std::shared_ptr<std::thread> > _threads;
        std::vector<std::shared_ptr<BaseResultType> > _results;
 
        void threadCb(std::shared_ptr<INode> &node);
index 0ac19608f11e2e72bd44f6ef75fec3159fb4add3..abaf0b0828f8b931b6ccd7bb9f42162407347f72 100644 (file)
@@ -120,6 +120,8 @@ void TaskManager::run()
                throw InvalidOperation("No input source.");
        }
 
+       std::vector<std::unique_ptr<std::thread> > threads;
+
        for (auto &n : _nodes) {
                // Set input as source of current node.
                // If no dependency then this node has to receive input source
@@ -141,14 +143,13 @@ void TaskManager::run()
                for (auto &d : dependencies)
                        d->wait();
 
-               _threads.push_back(make_shared<thread>(&TaskManager::threadCb, this, std::ref(n)));
+               threads.push_back(make_unique<thread>(&TaskManager::threadCb, this, std::ref(n)));
        }
 
-       for (auto &t : _threads)
+       for (auto &t : threads)
                t->join();
 
        _inputs.clear();
-       _threads.clear();
 }
 
 vector<shared_ptr<BaseResultType> > &TaskManager::output()