blob: 2fba1ada1baf2123b90c40a4ba0672daba7d7dd8 (
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
34
35
36
37
38
39
40
41
42
43
|
// Copyright 2021 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_HEAP_CPPGC_PLATFORM_H_
#define V8_HEAP_CPPGC_PLATFORM_H_
#include <string>
#include "include/cppgc/source-location.h"
#include "src/base/macros.h"
namespace cppgc {
namespace internal {
class HeapBase;
class V8_EXPORT_PRIVATE FatalOutOfMemoryHandler final {
public:
using Callback = void(const std::string&, const SourceLocation&, HeapBase*);
FatalOutOfMemoryHandler() = default;
explicit FatalOutOfMemoryHandler(HeapBase* heap) : heap_(heap) {}
[[noreturn]] void operator()(
const std::string& reason = std::string(),
const SourceLocation& = SourceLocation::Current()) const;
void SetCustomHandler(Callback*);
// Disallow copy/move.
FatalOutOfMemoryHandler(const FatalOutOfMemoryHandler&) = delete;
FatalOutOfMemoryHandler& operator=(const FatalOutOfMemoryHandler&) = delete;
private:
HeapBase* heap_ = nullptr;
Callback* custom_handler_ = nullptr;
};
} // namespace internal
} // namespace cppgc
#endif // V8_HEAP_CPPGC_PLATFORM_H_
|