summaryrefslogtreecommitdiff
path: root/lib/worker.h
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-04-14 10:26:51 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2023-04-14 11:15:56 +0100
commit1cbf18ff8463946aa5a09ccf1d6873b222b912b6 (patch)
treeeb7921b1b2099a3d34928841734010d6e3f7701e /lib/worker.h
parentGlobal worker instance (diff)
downloadilt-1cbf18ff8463946aa5a09ccf1d6873b222b912b6.tar.bz2
ilt-1cbf18ff8463946aa5a09ccf1d6873b222b912b6.tar.xz
ilt-1cbf18ff8463946aa5a09ccf1d6873b222b912b6.zip
Simplify worker with jthread
Moves thread collection to bottom of class so threads are joined before job storage is destroyed.
Diffstat (limited to 'lib/worker.h')
-rw-r--r--lib/worker.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/worker.h b/lib/worker.h
index 136c50e..96593d9 100644
--- a/lib/worker.h
+++ b/lib/worker.h
@@ -33,13 +33,13 @@ private:
private:
void worker();
- using Threads = std::vector<std::thread>;
+ using Threads = std::vector<std::jthread>;
using ToDo = std::deque<WorkPtr>;
- Threads threads;
ToDo todo;
std::counting_semaphore<16> todoLen;
std::mutex todoMutex;
+ Threads threads;
static Worker instance;
};