[+] Added async semantic ->Then(...)

This commit is contained in:
Reece Wilson 2021-07-12 15:37:05 +01:00
parent 29e5593308
commit 28a840f71d
3 changed files with 12 additions and 1 deletions

View File

@ -85,6 +85,8 @@ namespace Aurora::Async
virtual AuSPtr<IWorkItem> SetSchedTime(AuUInt32 ms) = 0;
virtual AuSPtr<IWorkItem> SetSchedTimeNs(AuUInt64 ns) = 0;
virtual AuSPtr<IWorkItem> Then(const AuSPtr<IWorkItem> &next) = 0;
virtual AuSPtr<IWorkItem> Dispatch() = 0;
virtual bool BlockUntilComplete() = 0;

View File

@ -54,6 +54,7 @@ namespace Aurora::Async
return AU_SHARED_FROM_THIS;
}
AuSPtr<IWorkItem> WorkItem::WaitFor(const AuList<AuSPtr<IWorkItem>> &workItems)
{
bool status {};
@ -84,6 +85,13 @@ namespace Aurora::Async
return AU_SHARED_FROM_THIS;
}
AuSPtr<IWorkItem> WorkItem::Then(const AuSPtr<IWorkItem> &next)
{
auto that = AU_SHARED_FROM_THIS;
next->WaitFor(that);
next->Dispatch();
return that;
}
AuSPtr<IWorkItem> WorkItem::SetSchedTimeNs(AuUInt64 ns)
{

View File

@ -19,6 +19,7 @@ namespace Aurora::Async
AuSPtr<IWorkItem> WaitFor(const AuList<AuSPtr<IWorkItem>> &workItem) override;
AuSPtr<IWorkItem> SetSchedTime(AuUInt32 ms) override;
AuSPtr<IWorkItem> SetSchedTimeNs(AuUInt64 ns) override;
AuSPtr<IWorkItem> Then(const AuSPtr<IWorkItem> &next) override;
AuSPtr<IWorkItem> Dispatch() override;