WeakContainer.h 566 B

123456789101112131415161718192021222324252627282930313233
  1. /*
  2. * Copyright (c) 2021, Idan Horowitz <idan.horowitz@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/IntrusiveList.h>
  8. namespace JS {
  9. class WeakContainer {
  10. public:
  11. explicit WeakContainer(Heap&);
  12. virtual ~WeakContainer();
  13. virtual void remove_swept_cells(Badge<Heap>, Span<Cell*>) = 0;
  14. protected:
  15. void deregister();
  16. private:
  17. bool m_registered { true };
  18. Heap& m_heap;
  19. IntrusiveListNode<WeakContainer> m_list_node;
  20. public:
  21. using List = IntrusiveList<&WeakContainer::m_list_node>;
  22. };
  23. }