2022-09-07 20:30:31 +02:00
|
|
|
/*
|
2024-10-04 13:19:50 +02:00
|
|
|
* Copyright (c) 2022, Andreas Kling <andreas@ladybird.org>
|
2022-09-07 20:30:31 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "EventLoopPluginSerenity.h"
|
|
|
|
|
#include <AK/NonnullRefPtr.h>
|
|
|
|
|
#include <LibCore/EventLoop.h>
|
2022-09-21 19:33:57 +01:00
|
|
|
#include <LibWeb/Platform/TimerSerenity.h>
|
2022-09-07 20:30:31 +02:00
|
|
|
|
2022-09-21 19:33:57 +01:00
|
|
|
namespace Web::Platform {
|
2022-09-07 20:30:31 +02:00
|
|
|
|
|
|
|
|
EventLoopPluginSerenity::EventLoopPluginSerenity() = default;
|
|
|
|
|
EventLoopPluginSerenity::~EventLoopPluginSerenity() = default;
|
|
|
|
|
|
2023-04-21 12:13:04 +01:00
|
|
|
void EventLoopPluginSerenity::spin_until(JS::SafeFunction<bool()> goal_condition)
|
2022-09-07 20:30:31 +02:00
|
|
|
{
|
|
|
|
|
Core::EventLoop::current().spin_until(move(goal_condition));
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-21 12:13:04 +01:00
|
|
|
void EventLoopPluginSerenity::deferred_invoke(JS::SafeFunction<void()> function)
|
2022-09-07 20:30:31 +02:00
|
|
|
{
|
|
|
|
|
VERIFY(function);
|
|
|
|
|
Core::deferred_invoke(move(function));
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-30 21:37:08 +13:00
|
|
|
JS::NonnullGCPtr<Timer> EventLoopPluginSerenity::create_timer(JS::Heap& heap)
|
2022-09-07 20:30:31 +02:00
|
|
|
{
|
2024-10-30 21:37:08 +13:00
|
|
|
return TimerSerenity::create(heap);
|
2022-09-07 20:30:31 +02:00
|
|
|
}
|
|
|
|
|
|
2022-10-08 10:54:52 +02:00
|
|
|
void EventLoopPluginSerenity::quit()
|
|
|
|
|
{
|
|
|
|
|
Core::EventLoop::current().quit(0);
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-07 20:30:31 +02:00
|
|
|
}
|