AuroraRuntime/Source/Async/Async.hpp
Reece 9a93d4ec8d [+] Added the old RSA wrappers
[*] Prepare for implementing ECC (again)
2021-07-01 10:18:42 +01:00

47 lines
906 B
C++

/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: Async.hpp
Date: 2021-6-26
Author: Reece
***/
#pragma once
namespace Aurora::Async
{
class IAsyncRunnable
{
public:
virtual void RunAsync() = 0;
virtual void CancelAsync() {}
};
class AsyncFuncRunnable : public IAsyncRunnable
{
public:
std::function<void()> callback;
AsyncFuncRunnable(std::function<void()> &&callback) : callback(std::move(callback))
{}
AsyncFuncRunnable(const std::function<void()> &callback) : callback(callback)
{}
void RunAsync() override
{
try
{
callback();
}
catch (...)
{
Debug::PrintError();
}
}
};
void InitAsync();
void ShutdownAsync();
}