mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 15:10:19 +00:00
726f2cfb11
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.
31 lines
417 B
C++
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;
|
|
|
|
}
|