mirror of
https://github.com/LNH-team/pico-launcher.git
synced 2026-06-02 09:06:54 +02:00
Initial commit
This commit is contained in:
27
arm9/source/core/task/TaskFactory.h
Normal file
27
arm9/source/core/task/TaskFactory.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
#include "Task.h"
|
||||
|
||||
class TaskFactory
|
||||
{
|
||||
template <typename T>
|
||||
static T TaskResultToResultType(TaskResult<T> arg);
|
||||
|
||||
public:
|
||||
template <typename FuncType>
|
||||
static auto Create(const FuncType& function)
|
||||
{
|
||||
return FuncTask<decltype(TaskResultToResultType(function())), FuncType>(function);
|
||||
}
|
||||
|
||||
template <typename FuncType>
|
||||
static auto CreateOnHeap(const FuncType& function) -> Task<decltype(TaskResultToResultType(function()))>*
|
||||
{
|
||||
return new FuncTask<decltype(TaskResultToResultType(function())), FuncType>(function);
|
||||
}
|
||||
|
||||
template <typename FuncType>
|
||||
static auto CreateOnHeapUnique(const FuncType& function) -> std::unique_ptr<Task<decltype(TaskResultToResultType(function()))>>
|
||||
{
|
||||
return std::make_unique<FuncTask<decltype(TaskResultToResultType(function())), FuncType>>(function);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user