2021-06-12 05:23:33 +03:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2021, Idan Horowitz <idan.horowitz@serenityos.org>
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2021-07-21 19:57:41 +02:00
|
|
|
#include <AK/IntrusiveList.h>
|
2021-06-12 05:23:33 +03:00
|
|
|
|
|
|
|
|
namespace JS {
|
|
|
|
|
|
|
|
|
|
class WeakContainer {
|
|
|
|
|
public:
|
2021-07-21 19:57:41 +02:00
|
|
|
explicit WeakContainer(Heap&);
|
|
|
|
|
virtual ~WeakContainer();
|
2021-06-12 05:23:33 +03:00
|
|
|
|
2021-06-27 22:39:48 +02:00
|
|
|
virtual void remove_swept_cells(Badge<Heap>, Vector<Cell*>&) = 0;
|
2021-06-12 05:23:33 +03:00
|
|
|
|
2021-06-12 17:38:34 +03:00
|
|
|
protected:
|
2021-07-21 19:57:41 +02:00
|
|
|
void deregister();
|
2021-06-12 17:38:34 +03:00
|
|
|
|
2021-06-12 05:23:33 +03:00
|
|
|
private:
|
2021-06-12 17:38:34 +03:00
|
|
|
bool m_registered { true };
|
2021-06-12 05:23:33 +03:00
|
|
|
Heap& m_heap;
|
2021-07-21 19:57:41 +02:00
|
|
|
|
|
|
|
|
IntrusiveListNode<WeakContainer> m_list_node;
|
|
|
|
|
|
|
|
|
|
public:
|
2021-09-09 16:30:59 +04:30
|
|
|
using List = IntrusiveList<&WeakContainer::m_list_node>;
|
2021-06-12 05:23:33 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|