From f5cd19114ef036dd73bd6166235efa1d3c0f657d Mon Sep 17 00:00:00 2001 From: ancarola Date: Wed, 23 Jan 2019 16:47:53 +0100 Subject: Task debugging --- engine/include/serial/focusable.h | 2 +- engine/object.cpp | 2 +- engine/task.cpp | 29 ++++++++++++++++++++++------- 3 files changed, 24 insertions(+), 9 deletions(-) (limited to 'engine') diff --git a/engine/include/serial/focusable.h b/engine/include/serial/focusable.h index 4880ff8..008f7a3 100644 --- a/engine/include/serial/focusable.h +++ b/engine/include/serial/focusable.h @@ -1,7 +1,7 @@ #ifndef __FOCUSABLE_H__ #define __FOCUSABLE_H__ -#include "object.hpp" +#include "core/object.hpp" #include "types.hpp" class task_s; diff --git a/engine/object.cpp b/engine/object.cpp index b6a22fd..7134061 100644 --- a/engine/object.cpp +++ b/engine/object.cpp @@ -1,4 +1,4 @@ -#include "object.hpp" +#include "core/object.hpp" #include diff --git a/engine/task.cpp b/engine/task.cpp index f2b6058..7f1b08b 100644 --- a/engine/task.cpp +++ b/engine/task.cpp @@ -3,6 +3,11 @@ #include #include +#include + +#include + +using namespace std; namespace flat { namespace core { @@ -10,22 +15,32 @@ namespace flat { : m_callback(f) {} std::shared_ptr job::make_task(task::callback f, priority_t p) { + auto shared = std::make_shared(f, p); insert(shared); return shared; } void job::invoke_tasks() { - std::for_each(begin(), end(), [&](auto tp) { + //std::for_each(begin(), end(), [&](auto tp) { + + vector> to_erase; + + for (auto tp : (*this)) { + if (tp.expired()) + to_erase.push_back(tp); + } + + for (auto tp : to_erase) + erase(tp); + + for (auto tp : (*this)) { // check that the task has not expired - if (auto t = tp.lock()) { // run task + auto t = tp.lock(); std::invoke(*t); - } else { - // delete task - erase(tp); - } - }); + } } + } } -- cgit v1.2.1