[*] Ensure failure on waiters if a task we're waiting on has already failed

This commit is contained in:
Reece Wilson 2021-06-30 10:34:01 +01:00
parent 452b49b610
commit 23ddb0f2f6

View File

@ -45,6 +45,12 @@ namespace Aurora::Async
{
auto dependency = std::reinterpret_pointer_cast<WorkItem>(workItem);
Threading::LockGuard<Threading::Primitives::SpinLock> l2(dependency->lock);
if (dependency->HasFailed())
{
Fail();
}
dependency->waiters_.push_back(shared_from_this());
waitOn_.push_back(workItem);
}
@ -77,6 +83,11 @@ namespace Aurora::Async
dispatchPending_ = true;
}
if (HasFailed())
{
return;
}
for (auto itr = waitOn_.begin(); itr != waitOn_.end(); )
{
auto &waitable = *itr;
@ -98,9 +109,9 @@ namespace Aurora::Async
SendOff();
}
void WorkItem::CancelAsync()
{
Threading::LockGuard<Threading::Primitives::SpinLock> l(lock);
Fail();
}
@ -130,8 +141,9 @@ namespace Aurora::Async
SetSchedTime(info.reschedMs);
}
WaitFor(info.waitFor);
// fall through
}
[[fallthrough]];
case IWorkItemHandler::EProcessNext::eRerun:
{
DispatchEx(false);