EventLoopPluginSerenity.cpp 905 B

123456789101112131415161718192021222324252627282930313233343536373839
  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/Function.h>
  8. #include <AK/NonnullRefPtr.h>
  9. #include <LibCore/EventLoop.h>
  10. #include <LibWeb/Platform/TimerSerenity.h>
  11. namespace Web::Platform {
  12. EventLoopPluginSerenity::EventLoopPluginSerenity() = default;
  13. EventLoopPluginSerenity::~EventLoopPluginSerenity() = default;
  14. void EventLoopPluginSerenity::spin_until(Function<bool()> goal_condition)
  15. {
  16. Core::EventLoop::current().spin_until(move(goal_condition));
  17. }
  18. void EventLoopPluginSerenity::deferred_invoke(Function<void()> function)
  19. {
  20. VERIFY(function);
  21. Core::deferred_invoke(move(function));
  22. }
  23. NonnullRefPtr<Timer> EventLoopPluginSerenity::create_timer()
  24. {
  25. return TimerSerenity::create();
  26. }
  27. void EventLoopPluginSerenity::quit()
  28. {
  29. Core::EventLoop::current().quit(0);
  30. }
  31. }