AuroraRuntime/Include/Aurora/Async/Tasks.hpp

47 lines
1.1 KiB
C++
Raw Normal View History

/***
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>;
}