ladybird/Libraries/LibGC/DeferGC.h
Andrew Kaster 726f2cfb11 LibGC: Expose deferred state publicly, annotate DeferGC for Swift
While we don't want arbitrary callers deferring GC, we do want
deferral to be available to the Swift. In order for Swift to
understand the RAII nature of DeferGC, we need to mark it as
non-copyable.
2024-11-19 14:32:11 -07:00

31 lines
417 B
C++

/*
* Copyright (c) 2020, Andreas Kling <andreas@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Swift.h>
#include <LibGC/Heap.h>
namespace GC {
class DeferGC {
public:
explicit DeferGC(Heap& heap)
: m_heap(heap)
{
m_heap.defer_gc();
}
~DeferGC()
{
m_heap.undefer_gc();
}
private:
Heap& m_heap;
} SWIFT_NONCOPYABLE;
}