EventLoopPluginSerenity.cpp 896 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. * Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include "EventLoopPluginSerenity.h"
  7. #include <AK/NonnullRefPtr.h>
  8. #include <LibCore/EventLoop.h>
  9. #include <LibWeb/Platform/TimerSerenity.h>
  10. namespace Web::Platform {
  11. EventLoopPluginSerenity::EventLoopPluginSerenity() = default;
  12. EventLoopPluginSerenity::~EventLoopPluginSerenity() = default;
  13. void EventLoopPluginSerenity::spin_until(JS::SafeFunction<bool()> goal_condition)
  14. {
  15. Core::EventLoop::current().spin_until(move(goal_condition));
  16. }
  17. void EventLoopPluginSerenity::deferred_invoke(JS::SafeFunction<void()> function)
  18. {
  19. VERIFY(function);
  20. Core::deferred_invoke(move(function));
  21. }
  22. NonnullRefPtr<Timer> EventLoopPluginSerenity::create_timer()
  23. {
  24. return TimerSerenity::create();
  25. }
  26. void EventLoopPluginSerenity::quit()
  27. {
  28. Core::EventLoop::current().quit(0);
  29. }
  30. }