RefCountedFlag.h 598 B

12345678910111213141516171819202122232425262728
  1. /*
  2. * Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/RefCounted.h>
  8. namespace Web::Fetch::Fetching {
  9. /// A ref-counted boolean flag.
  10. /// This is used to share flags between multiple callback closures.
  11. class RefCountedFlag : public RefCounted<RefCountedFlag> {
  12. public:
  13. static NonnullRefPtr<RefCountedFlag> create(bool);
  14. [[nodiscard]] bool value() const { return m_value; }
  15. void set_value(bool value) { m_value = value; }
  16. private:
  17. explicit RefCountedFlag(bool);
  18. bool m_value { false };
  19. };
  20. }