Reece
3a62400ac1
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.
47 lines
1.1 KiB
C++
47 lines
1.1 KiB
C++
/***
|
|
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
File: Tasks.hpp
|
|
Date: 2021-11-1
|
|
Author: Reece
|
|
***/
|
|
#pragma once
|
|
|
|
namespace Aurora::Async
|
|
{
|
|
template<class Info_t = AVoid, class Result_t = AVoid>
|
|
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 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>;
|
|
} |