mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-25 02:38:59 +00:00
Everywhere: Hoist the Libraries folder to the top-level
This commit is contained in:
parent
950e819ee7
commit
93712b24bf
Notes:
github-actions[bot]
2024-11-10 11:51:52 +00:00
Author: https://github.com/trflynn89
Commit: 93712b24bf
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2256
Reviewed-by: https://github.com/sideshowbarker
4547 changed files with 104 additions and 113 deletions
57
Libraries/LibJS/Runtime/FinalizationRegistry.h
Normal file
57
Libraries/LibJS/Runtime/FinalizationRegistry.h
Normal file
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* Copyright (c) 2021-2022, Idan Horowitz <idan.horowitz@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/SinglyLinkedList.h>
|
||||
#include <LibJS/Heap/GCPtr.h>
|
||||
#include <LibJS/Runtime/FunctionObject.h>
|
||||
#include <LibJS/Runtime/GlobalObject.h>
|
||||
#include <LibJS/Runtime/JobCallback.h>
|
||||
#include <LibJS/Runtime/Object.h>
|
||||
#include <LibJS/Runtime/Value.h>
|
||||
#include <LibJS/Runtime/WeakContainer.h>
|
||||
|
||||
namespace JS {
|
||||
|
||||
class FinalizationRegistry final
|
||||
: public Object
|
||||
, public WeakContainer {
|
||||
JS_OBJECT(FinalizationRegistry, Object);
|
||||
JS_DECLARE_ALLOCATOR(FinalizationRegistry);
|
||||
|
||||
public:
|
||||
virtual ~FinalizationRegistry() override = default;
|
||||
|
||||
void add_finalization_record(Cell& target, Value held_value, Cell* unregister_token);
|
||||
bool remove_by_token(Cell& unregister_token);
|
||||
ThrowCompletionOr<void> cleanup(GCPtr<JobCallback> = {});
|
||||
|
||||
virtual void remove_dead_cells(Badge<Heap>) override;
|
||||
|
||||
Realm& realm() { return *m_realm; }
|
||||
Realm const& realm() const { return *m_realm; }
|
||||
|
||||
JobCallback& cleanup_callback() { return *m_cleanup_callback; }
|
||||
JobCallback const& cleanup_callback() const { return *m_cleanup_callback; }
|
||||
|
||||
private:
|
||||
FinalizationRegistry(Realm&, NonnullGCPtr<JobCallback>, Object& prototype);
|
||||
|
||||
virtual void visit_edges(Visitor& visitor) override;
|
||||
|
||||
NonnullGCPtr<Realm> m_realm;
|
||||
NonnullGCPtr<JobCallback> m_cleanup_callback;
|
||||
|
||||
struct FinalizationRecord {
|
||||
GCPtr<Cell> target;
|
||||
Value held_value;
|
||||
GCPtr<Cell> unregister_token;
|
||||
};
|
||||
SinglyLinkedList<FinalizationRecord> m_records;
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue