diff options
| author | Mel <einebeere@gmail.com> | 2023-07-08 03:25:44 +0200 |
|---|---|---|
| committer | Mel <einebeere@gmail.com> | 2023-07-08 03:25:44 +0200 |
| commit | fe2baedc760c2f29e2c720f6b1132a2de33c5430 (patch) | |
| tree | dfbe1c72a17805a3cab6e0d47433e9021890c9ca /src/Compute | |
| parent | 41fbca10f6c6cdd9c1623f1347e7ecb40f5e7f59 (diff) | |
| download | meowcraft-fe2baedc760c2f29e2c720f6b1132a2de33c5430.tar.zst meowcraft-fe2baedc760c2f29e2c720f6b1132a2de33c5430.zip | |
Use own size types
Diffstat (limited to 'src/Compute')
| -rw-r--r-- | src/Compute/Queue.hpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/Compute/Queue.hpp b/src/Compute/Queue.hpp index 77aed7f..4035d56 100644 --- a/src/Compute/Queue.hpp +++ b/src/Compute/Queue.hpp @@ -1,7 +1,7 @@ #pragma once +#include "../Common/Sizes.hpp" #include <functional> -#include <sys/types.h> #include <mutex> #include <vector> #include <queue> @@ -9,17 +9,17 @@ namespace MC::Compute { -template <typename X, typename I = uint> +template <typename X, typename I = UInt> class Queue { public: - explicit Queue(uint workers) : m_control(std::make_shared<Control>()) { - for (uint w = 0; w < workers; w++) { + explicit Queue(UInt workers) : m_control(std::make_shared<Control>()) { + for (UInt w = 0; w < workers; w++) { std::thread thread{[=]{ Queue::run_thread(m_control); }}; thread.detach(); } } - void add(I id, float priority, std::function<X()> execute) { + void add(I id, Real priority, std::function<X()> execute) { std::scoped_lock work_lock(m_control->work.mutex); m_control->work.jobs.emplace(id, priority, execute); } @@ -43,13 +43,13 @@ public: private: struct Job { Job() = default; - Job(I id, float priority, std::function<X()> execute) : id(id), priority(priority), execute(execute) {} + Job(I id, Real priority, std::function<X()> execute) : id(id), priority(priority), execute(execute) {} I id; - float priority; + Real priority; std::function<X()> execute; - bool operator>(const Job& other) const { return priority > other.priority; } + Bool operator>(const Job& other) const { return priority > other.priority; } }; struct Work { @@ -71,7 +71,7 @@ private: using namespace std::chrono_literals; while (true) { - bool nothing_to_do = true; + Bool nothing_to_do = true; Job job; { std::scoped_lock work_lock(control->work.mutex); |
