2020-04-19 09:30:47 +00:00
|
|
|
/*
|
2024-10-04 11:19:50 +00:00
|
|
|
* Copyright (c) 2020, Andreas Kling <andreas@ladybird.org>
|
2020-04-19 09:30:47 +00:00
|
|
|
*
|
2021-04-22 08:24:48 +00:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-04-19 09:30:47 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2024-11-17 01:45:19 +00:00
|
|
|
#include <AK/Swift.h>
|
2024-11-14 15:01:23 +00:00
|
|
|
#include <LibGC/Heap.h>
|
2020-04-19 09:30:47 +00:00
|
|
|
|
2024-11-14 15:01:23 +00:00
|
|
|
namespace GC {
|
2020-04-19 09:30:47 +00:00
|
|
|
|
|
|
|
class DeferGC {
|
|
|
|
public:
|
|
|
|
explicit DeferGC(Heap& heap)
|
|
|
|
: m_heap(heap)
|
|
|
|
{
|
2023-09-23 11:44:13 +00:00
|
|
|
m_heap.defer_gc();
|
2020-04-19 09:30:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
~DeferGC()
|
|
|
|
{
|
2023-09-23 11:44:13 +00:00
|
|
|
m_heap.undefer_gc();
|
2020-04-19 09:30:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
Heap& m_heap;
|
2024-11-17 01:45:19 +00:00
|
|
|
} SWIFT_NONCOPYABLE;
|
2020-04-19 09:30:47 +00:00
|
|
|
|
|
|
|
}
|