[deploy] add callback runner

This commit is contained in:
Nomango 2022-06-07 15:16:59 +08:00
parent 3fc100185c
commit f0ed620443
2 changed files with 34 additions and 1 deletions

View File

@ -43,6 +43,31 @@ Application::~Application()
{ {
} }
void Application::Run(const Settings& settings, const Function<void()>& setup)
{
KGE_ASSERT(setup);
class CallbackRunner : public Runner
{
public:
Function<void()> setup;
CallbackRunner(const Function<void()>& setup)
: setup(setup)
{
}
void OnReady() override
{
setup();
}
};
RunnerPtr runner = new CallbackRunner(setup);
runner->SetName("__KGE_CALLBACK_RUNNER__");
runner->SetSettings(settings);
Run(runner);
}
void Application::Run(RunnerPtr runner) void Application::Run(RunnerPtr runner)
{ {
KGE_ASSERT(runner); KGE_ASSERT(runner);

View File

@ -52,11 +52,19 @@ public:
virtual ~Application(); virtual ~Application();
/**
* \~chinese
* @brief
* @param settings
* @param setup
* @note
*/
void Run(const Settings& settings, const Function<void()>& setup);
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @param runner * @param runner
* @param debug
* @note * @note
*/ */
void Run(RunnerPtr runner); void Run(RunnerPtr runner);