diff options
Diffstat (limited to '')
-rw-r--r-- | engine/include/core/priority.hpp | 18 | ||||
-rw-r--r-- | engine/include/core/task.hpp | 4 | ||||
-rw-r--r-- | engine/task.cpp | 2 |
3 files changed, 16 insertions, 8 deletions
diff --git a/engine/include/core/priority.hpp b/engine/include/core/priority.hpp index 0f00006..773b2f7 100644 --- a/engine/include/core/priority.hpp +++ b/engine/include/core/priority.hpp @@ -4,7 +4,6 @@ namespace flat { namespace core { - enum class priority_t : unsigned { max = 0, higher = 1, @@ -27,10 +26,19 @@ namespace flat { return m_priority; } }; - - bool operator<(const prioritized& lhs, const prioritized& rhs) { - return lhs.priority() < rhs.priority(); - } + + struct prioritize { + bool operator()(const prioritized& lhs, const prioritized& rhs) { + return lhs.priority() < rhs.priority(); + } + + bool operator()(const prioritized * const& lhs, const prioritized * const& rhs) { + return lhs->priority() < rhs->priority(); + } + }; + + template<typename Prioritized> + using queue = std::multiset<Prioritized, prioritize>; } } diff --git a/engine/include/core/task.hpp b/engine/include/core/task.hpp index b6ddad1..90e3d97 100644 --- a/engine/include/core/task.hpp +++ b/engine/include/core/task.hpp @@ -18,7 +18,7 @@ namespace flat { std::function<void()> m_callback; }; - struct job : public std::multiset<task> { + struct job : public queue<task> { inline auto add_task(task t) { this->insert(t); } @@ -26,4 +26,4 @@ namespace flat { void invoke_tasks(); }; } -}
\ No newline at end of file +} diff --git a/engine/task.cpp b/engine/task.cpp index f879530..760b1b9 100644 --- a/engine/task.cpp +++ b/engine/task.cpp @@ -14,4 +14,4 @@ namespace flat { } } } -}
\ No newline at end of file +} |