TaskQueue.h 571 B

123456789101112131415161718192021222324252627282930
  1. /*
  2. * Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/Queue.h>
  8. #include <LibWeb/HTML/EventLoop/Task.h>
  9. namespace Web::HTML {
  10. class TaskQueue {
  11. public:
  12. explicit TaskQueue(HTML::EventLoop&);
  13. ~TaskQueue();
  14. bool is_empty() const { return m_tasks.is_empty(); }
  15. void add(NonnullOwnPtr<HTML::Task>);
  16. OwnPtr<HTML::Task> take_first_runnable() { return m_tasks.dequeue(); }
  17. private:
  18. HTML::EventLoop& m_event_loop;
  19. Queue<NonnullOwnPtr<HTML::Task>> m_tasks;
  20. };
  21. }