TaskQueue.h 510 B

12345678910111213141516171819202122232425262728
  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. TaskQueue();
  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. Queue<NonnullOwnPtr<HTML::Task>> m_tasks;
  19. };
  20. }