WeakSet.h 747 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/HashTable.h>
  8. #include <LibJS/Runtime/GlobalObject.h>
  9. #include <LibJS/Runtime/Object.h>
  10. namespace JS {
  11. class WeakSet : public Object {
  12. JS_OBJECT(WeakSet, Object);
  13. public:
  14. static WeakSet* create(GlobalObject&);
  15. explicit WeakSet(Object& prototype);
  16. virtual ~WeakSet() override;
  17. HashTable<Cell*> const& values() const { return m_values; };
  18. HashTable<Cell*>& values() { return m_values; };
  19. void remove_sweeped_cells(Badge<Heap>, Vector<Cell*>&);
  20. private:
  21. HashTable<Cell*> m_values; // This stores Cell pointers instead of Object pointers to aide with sweeping
  22. };
  23. }