[+] Added IWorkItem::Cancel

This commit is contained in:
Reece Wilson 2021-09-29 09:01:42 +01:00
parent 60d2c59d6e
commit 8a6abcfdb7
2 changed files with 13 additions and 0 deletions

View File

@ -271,6 +271,12 @@ namespace Aurora::Async
return finished;
}
void WorkItem::Cancel()
{
AU_LOCK_GUARD(lock);
Fail();
}
bool WorkItem::HasFailed()
{
return failed;
@ -288,6 +294,11 @@ namespace Aurora::Async
AUKN_SYM AuSPtr<IWorkItem> NewWorkItem(const DispatchTarget_t &worker, const AuSPtr<IWorkItemHandler> &task, bool supportsBlocking)
{
if (!task)
{
SysPushErrorNested("Constructed workitem with a null task. running on stack and reserve heaps alone?");
return {};
}
return AuMakeShared<WorkItem>(worker, task, supportsBlocking);
}
}

View File

@ -29,6 +29,8 @@ namespace Aurora::Async
bool HasFinished() override;
bool HasFailed() override;
void Cancel() override;
void RunAsync() override;
void CancelAsync() override;