[+] Added Async::ITask

Reece, [07/11/2021 20:10]
technically legal template odr

Reece, [07/11/2021 20:11]
either we resolve the vtable from an api that returns a shared pointer of the implementation. The inline keyword should help with linking. Seems to work.

Reece, [07/11/2021 20:11]
or we just have the C/FTask impl in which case some compilers will C-inline the jmp target through the final hints. Connfirmed under MSVC and GCC.
This commit is contained in:
Reece Wilson 2021-11-07 20:16:20 +00:00
parent 7211c25936
commit 3a62400ac1
2 changed files with 20 additions and 5 deletions

View File

@ -10,22 +10,37 @@
namespace Aurora::Async
{
template<class Info_t = AVoid, class Result_t = AVoid>
struct FTask
struct ITask
{
virtual Result_t OnFrame(const Info_t &in) const = 0;
};
template<class Info_t = AVoid, class Result_t = AVoid>
struct FTask final : ITask<Info_t, Result_t>
{
using InfoType_t = Info_t;
using ResultType_t = Result_t;
AuFunction<Result_t(const Info_t &)> onFrame;
virtual inline Result_t OnFrame(const Info_t &in) const override final
{
return onFrame(in);
}
};
template<class Info_t = AVoid, class Result_t = AVoid>
struct CTask
struct CTask final : ITask<Info_t, Result_t>
{
using InfoType_t = Info_t;
using ResultType_t = Result_t;
Result_t(* onFrame)(const Info_t &) = 0;
virtual inline Result_t OnFrame(const Info_t &in) const override final
{
return onFrame(in);
}
};
using FVoidTask = FTask<AVoid, AVoid>;

View File

@ -247,11 +247,11 @@ namespace Aurora::Async
{
if constexpr (IsTaskPtr)
{
resultValue_ = task->onFrame(input);
resultValue_ = task->OnFrame(input);
}
else
{
resultValue_ = task.onFrame(input);
resultValue_ = task.OnFrame(input);
}
task = {};