[*] Prevent pinning another WorkItems lock within the parent scope of some ::Fail's

This commit is contained in:
Reece Wilson 2021-06-30 10:41:58 +01:00
parent 6de84b474e
commit e30be64c44

View File

@ -27,17 +27,34 @@ namespace Aurora::Async
}
void WorkItem::WaitFor(const AuSPtr<IWorkItem> &workItem)
{
bool status {};
{
auto dependency = std::reinterpret_pointer_cast<WorkItem>(workItem);
Threading::LockGuard<Threading::Primitives::SpinLock> l(lock);
Threading::LockGuard<Threading::Primitives::SpinLock> l2(dependency->lock);
if (dependency->HasFailed())
{
status = true;
}
dependency->waiters_.push_back(shared_from_this());
waitOn_.push_back(workItem);
}
if (status)
{
Fail();
}
}
void WorkItem::WaitFor(const AuList<AuSPtr<IWorkItem>> &workItems)
{
bool status {};
{
Threading::LockGuard<Threading::Primitives::SpinLock> l(lock);
@ -48,7 +65,7 @@ namespace Aurora::Async
if (dependency->HasFailed())
{
Fail();
status = true;
}
dependency->waiters_.push_back(shared_from_this());
@ -56,6 +73,12 @@ namespace Aurora::Async
}
}
if (status)
{
Fail();
}
}
void WorkItem::SetSchedTime(AuUInt32 ms)
{
Threading::LockGuard<Threading::Primitives::SpinLock> l(lock);