summaryrefslogtreecommitdiffstats
path: root/engine/include/core/task.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'engine/include/core/task.hpp')
-rw-r--r--engine/include/core/task.hpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/engine/include/core/task.hpp b/engine/include/core/task.hpp
index 90e3d97..d886fcd 100644
--- a/engine/include/core/task.hpp
+++ b/engine/include/core/task.hpp
@@ -3,26 +3,29 @@
#include "priority.hpp"
#include <functional>
-#include <set>
+#include <memory>
namespace flat {
namespace core {
+ // forward decl
+ class job;
+ class task;
+
class task : public prioritized {
public:
+ using callback = std::function<void(void)>;
+
task() = delete;
- task(std::function<void()> callback, priority_t p = priority_t::none);
+ task(callback f, priority_t p = priority_t::none);
inline void operator()() const { m_callback(); }
private:
- std::function<void()> m_callback;
+ callback m_callback;
};
- struct job : public queue<task> {
- inline auto add_task(task t) {
- this->insert(t);
- }
-
+ struct job : private queue<std::weak_ptr<task>> {
+ std::shared_ptr<task> make_task(task::callback f, priority_t p = priority_t::none);
void invoke_tasks();
};
}