From dae28a9db5e78d12086436900c3a0dff4bd0bf5a Mon Sep 17 00:00:00 2001 From: Patrick Wuttke Date: Sun, 5 Feb 2023 14:30:16 +0100 Subject: [PATCH] Made task releasing actually work. --- include/Task.h | 12 +++++++++++- include/TaskManager.h | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/include/Task.h b/include/Task.h index 6a18a77..4bae066 100644 --- a/include/Task.h +++ b/include/Task.h @@ -263,6 +263,16 @@ public: m_taskInternal = std::move(in_otherTask.m_taskInternal); return *this; } + template + bool operator ==(const Task& in_otherTask) noexcept + { + return m_taskInternal == in_otherTask.m_taskInternal; + } + template + bool operator !=(const Task& in_otherTask) noexcept + { + return m_taskInternal != in_otherTask.m_taskInternal; + } ~Task() /// Destructor { RemoveRef(); // Remove logical reference task @@ -274,7 +284,7 @@ public: { return m_taskInternal.get(); } - operator bool() const /// Conversion-to-bool that yields whether an underlying coroutine is set for the task + explicit operator bool() const /// Conversion-to-bool that yields whether an underlying coroutine is set for the task { return IsValid(); } diff --git a/include/TaskManager.h b/include/TaskManager.h index 6822634..545d7c1 100644 --- a/include/TaskManager.h +++ b/include/TaskManager.h @@ -140,6 +140,7 @@ public: { auto itWeak = std::find(m_tasks.begin(), m_tasks.end(), in_task); assert(itWeak != m_tasks.end()); + *itWeak = nullptr; // otherwise the next line will kill the task (in destructor) m_tasks.erase(itWeak); auto itStrong = std::find(m_strongRefs.begin(), m_strongRefs.end(), in_task);