summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Runtime/WeakContainer.h
blob: 8e469fb9ed54f505482c7017aa6569c00c428ee2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
 * Copyright (c) 2021, Idan Horowitz <idan.horowitz@serenityos.org>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <AK/IntrusiveList.h>

namespace JS {

class WeakContainer {
public:
    explicit WeakContainer(Heap&);
    virtual ~WeakContainer();

    virtual void remove_swept_cells(Badge<Heap>, Vector<Cell*>&) = 0;

protected:
    void deregister();

private:
    bool m_registered { true };
    Heap& m_heap;

    IntrusiveListNode<WeakContainer> m_list_node;

public:
    using List = IntrusiveList<&WeakContainer::m_list_node>;
};

}