summaryrefslogtreecommitdiff
path: root/lib/worker.h
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-04-14 10:24:10 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2023-04-14 10:24:10 +0100
commit4bf94458d5d7abafb154e914620dc758d26719c2 (patch)
tree95a1d5db3c27b0069318798c90dc5e8ff093dc1f /lib/worker.h
parentExternalise a neater definition of TGAHead (diff)
downloadilt-4bf94458d5d7abafb154e914620dc758d26719c2.tar.bz2
ilt-4bf94458d5d7abafb154e914620dc758d26719c2.tar.xz
ilt-4bf94458d5d7abafb154e914620dc758d26719c2.zip
Global worker instance
Diffstat (limited to 'lib/worker.h')
-rw-r--r--lib/worker.h35
1 files changed, 10 insertions, 25 deletions
diff --git a/lib/worker.h b/lib/worker.h
index 7cd06f9..136c50e 100644
--- a/lib/worker.h
+++ b/lib/worker.h
@@ -1,19 +1,17 @@
#pragma once
+#include <deque>
+#include <memory>
+#include <mutex>
+#include <semaphore>
+#include <special_members.hpp>
+#include <thread>
#include <utility>
-class Work;
-
-#if __cpp_lib_semaphore
-# include <deque>
-# include <memory>
-# include <mutex>
-# include <semaphore>
-# include <special_members.hpp>
-# include <thread>
-# include <vector>
+#include <vector>
+class Work;
class Worker {
-public:
+private:
Worker();
~Worker();
@@ -42,19 +40,6 @@ private:
ToDo todo;
std::counting_semaphore<16> todoLen;
std::mutex todoMutex;
-};
-
-#else
-class Worker {
-public:
- template<typename T, typename... Params>
- void
- addWork(Params &&... params)
- requires std::is_base_of_v<Work, T>
- {
- T(std::forward<Params>(params)...).doWork();
- }
+ static Worker instance;
};
-
-#endif