From 0ebf41a9cb23b033e5fd117c7dab1298440763b9 Mon Sep 17 00:00:00 2001 From: Shinwoo Kim Date: Mon, 24 Aug 2020 17:06:26 +0900 Subject: [PATCH] taskscheduler: initialize member correctly This patch will fix runtime crash caused by incorrect init variables. --- src/lib/tvgTaskScheduler.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/tvgTaskScheduler.cpp b/src/lib/tvgTaskScheduler.cpp index 31b1e849..e7df53a9 100644 --- a/src/lib/tvgTaskScheduler.cpp +++ b/src/lib/tvgTaskScheduler.cpp @@ -101,11 +101,12 @@ class TaskSchedulerImpl public: unsigned threadCnt; vector threads; - vector taskQueues{threadCnt}; + vector taskQueues; atomic idx{0}; - TaskSchedulerImpl() + TaskSchedulerImpl(unsigned count) : taskQueues(count) { + threadCnt = count; for (unsigned i = 0; i < threadCnt; ++i) { threads.emplace_back([&, i] { run(i); }); } @@ -168,8 +169,7 @@ static TaskSchedulerImpl* inst = nullptr; void TaskScheduler::init(unsigned threads) { if (inst) return; - inst = new TaskSchedulerImpl; - inst->threadCnt = threads; + inst = new TaskSchedulerImpl(threads); }