v8 12.4.254 (node 22.4.1)
V8 is Google's open source JavaScript engine
Loading...
Searching...
No Matches
v8-microtask-queue.h
Go to the documentation of this file.
1// Copyright 2021 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef INCLUDE_V8_MICROTASKS_QUEUE_H_
6#define INCLUDE_V8_MICROTASKS_QUEUE_H_
7
8#include <stddef.h>
9
10#include <memory>
11
12#include "v8-local-handle.h" // NOLINT(build/include_directory)
13#include "v8-microtask.h" // NOLINT(build/include_directory)
14#include "v8config.h" // NOLINT(build/include_directory)
15
16namespace v8 {
17
18class Function;
19
20namespace internal {
21class Isolate;
22class MicrotaskQueue;
23} // namespace internal
24
41 public:
45 static std::unique_ptr<MicrotaskQueue> New(
46 Isolate* isolate, MicrotasksPolicy policy = MicrotasksPolicy::kAuto);
47
48 virtual ~MicrotaskQueue() = default;
49
53 virtual void EnqueueMicrotask(Isolate* isolate,
54 Local<Function> microtask) = 0;
55
59 virtual void EnqueueMicrotask(v8::Isolate* isolate,
60 MicrotaskCallback callback,
61 void* data = nullptr) = 0;
62
76 MicrotasksCompletedCallbackWithData callback, void* data = nullptr) = 0;
77
82 MicrotasksCompletedCallbackWithData callback, void* data = nullptr) = 0;
83
87 virtual void PerformCheckpoint(Isolate* isolate) = 0;
88
92 virtual bool IsRunningMicrotasks() const = 0;
93
98 virtual int GetMicrotasksScopeDepth() const = 0;
99
102
103 private:
104 friend class internal::MicrotaskQueue;
105 MicrotaskQueue() = default;
106};
107
118 public:
119 enum Type { kRunMicrotasks, kDoNotRunMicrotasks };
120
122 "May be incorrect if context was created with non-default microtask "
123 "queue")
124 MicrotasksScope(Isolate* isolate, Type type);
125
127 MicrotasksScope(Isolate* isolate, MicrotaskQueue* microtask_queue, Type type);
129
133 static void PerformCheckpoint(Isolate* isolate);
134
138 static int GetCurrentDepth(Isolate* isolate);
139
143 static bool IsRunningMicrotasks(Isolate* isolate);
144
145 // Prevent copying.
147 MicrotasksScope& operator=(const MicrotasksScope&) = delete;
148
149 private:
150 internal::Isolate* const i_isolate_;
151 internal::MicrotaskQueue* const microtask_queue_;
152 bool run_;
153};
154
155} // namespace v8
156
157#endif // INCLUDE_V8_MICROTASKS_QUEUE_H_
virtual void RemoveMicrotasksCompletedCallback(MicrotasksCompletedCallbackWithData callback, void *data=nullptr)=0
virtual void AddMicrotasksCompletedCallback(MicrotasksCompletedCallbackWithData callback, void *data=nullptr)=0
virtual bool IsRunningMicrotasks() const =0
virtual void PerformCheckpoint(Isolate *isolate)=0
virtual ~MicrotaskQueue()=default
MicrotaskQueue & operator=(const MicrotaskQueue &)=delete
virtual int GetMicrotasksScopeDepth() const =0
static std::unique_ptr< MicrotaskQueue > New(Isolate *isolate, MicrotasksPolicy policy=MicrotasksPolicy::kAuto)
virtual void EnqueueMicrotask(Isolate *isolate, Local< Function > microtask)=0
virtual void EnqueueMicrotask(v8::Isolate *isolate, MicrotaskCallback callback, void *data=nullptr)=0
MicrotaskQueue(const MicrotaskQueue &)=delete
V8_DEPRECATE_SOON("May be incorrect if context was created with non-default microtask " "queue") MicrotasksScope(Isolate *isolate
void(*)(Isolate *, void *) MicrotasksCompletedCallbackWithData
void(*)(void *data) MicrotaskCallback
MicrotasksPolicy
#define V8_EXPORT
Definition v8config.h:753
#define V8_NODISCARD
Definition v8config.h:650