Implemented releasing of weak tasks.
This commit is contained in:
parent
10dc3c3e54
commit
2a762d216d
@ -136,6 +136,23 @@ public:
|
||||
m_tasks.push_back(std::move(in_task));
|
||||
}
|
||||
|
||||
bool IsManagedTask(const WeakTaskHandle& in_task)
|
||||
{
|
||||
return std::find(m_strongRefs.begin(), m_strongRefs.end(), in_task) != m_strongRefs.end();
|
||||
}
|
||||
|
||||
WeakTask ReleaseWeakTask(const WeakTaskHandle& in_task)
|
||||
{
|
||||
assert(!IsManagedTask(in_task));
|
||||
|
||||
auto itWeak = std::find(m_tasks.begin(), m_tasks.end(), in_task);
|
||||
assert(itWeak != m_tasks.end());
|
||||
WeakTask task = std::move(*itWeak);
|
||||
*itWeak = nullptr; // otherwise the next line will kill the task (in destructor)
|
||||
m_tasks.erase(itWeak);
|
||||
return task;
|
||||
}
|
||||
|
||||
Task<> ReleaseManagedTask(const WeakTaskHandle& in_task)
|
||||
{
|
||||
auto itWeak = std::find(m_tasks.begin(), m_tasks.end(), in_task);
|
||||
|
Loading…
x
Reference in New Issue
Block a user