Made task releasing actually work.

This commit is contained in:
2023-02-05 14:30:16 +01:00
parent c8edb195f4
commit dae28a9db5
2 changed files with 12 additions and 1 deletions

View File

@@ -263,6 +263,16 @@ public:
m_taskInternal = std::move(in_otherTask.m_taskInternal); m_taskInternal = std::move(in_otherTask.m_taskInternal);
return *this; return *this;
} }
template<typename tOtherRet, eTaskRef OtherRefType, eTaskResumable OtherResumable>
bool operator ==(const Task<tOtherRet, OtherRefType, OtherResumable>& in_otherTask) noexcept
{
return m_taskInternal == in_otherTask.m_taskInternal;
}
template<typename tOtherRet, eTaskRef OtherRefType, eTaskResumable OtherResumable>
bool operator !=(const Task<tOtherRet, OtherRefType, OtherResumable>& in_otherTask) noexcept
{
return m_taskInternal != in_otherTask.m_taskInternal;
}
~Task() /// Destructor ~Task() /// Destructor
{ {
RemoveRef(); // Remove logical reference task RemoveRef(); // Remove logical reference task
@@ -274,7 +284,7 @@ public:
{ {
return m_taskInternal.get(); 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(); return IsValid();
} }

View File

@@ -140,6 +140,7 @@ public:
{ {
auto itWeak = std::find(m_tasks.begin(), m_tasks.end(), in_task); auto itWeak = std::find(m_tasks.begin(), m_tasks.end(), in_task);
assert(itWeak != m_tasks.end()); assert(itWeak != m_tasks.end());
*itWeak = nullptr; // otherwise the next line will kill the task (in destructor)
m_tasks.erase(itWeak); m_tasks.erase(itWeak);
auto itStrong = std::find(m_strongRefs.begin(), m_strongRefs.end(), in_task); auto itStrong = std::find(m_strongRefs.begin(), m_strongRefs.end(), in_task);