v8 10.2.154 (node 18.16.0)
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
121 MicrotasksScope(Isolate* isolate, Type type);
122 MicrotasksScope(Isolate* isolate, MicrotaskQueue* microtask_queue, Type type);
124
128 static void PerformCheckpoint(Isolate* isolate);
129
133 static int GetCurrentDepth(Isolate* isolate);
134
138 static bool IsRunningMicrotasks(Isolate* isolate);
139
140 // Prevent copying.
143
144 private:
145 internal::Isolate* const isolate_;
146 internal::MicrotaskQueue* const microtask_queue_;
147 bool run_;
148};
149
150} // namespace v8
151
152#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
MicrotasksScope & operator=(const MicrotasksScope &)=delete
MicrotasksScope(Isolate *isolate, MicrotaskQueue *microtask_queue, Type type)
static bool IsRunningMicrotasks(Isolate *isolate)
MicrotasksScope(Isolate *isolate, Type type)
MicrotasksScope(const MicrotasksScope &)=delete
static void PerformCheckpoint(Isolate *isolate)
static int GetCurrentDepth(Isolate *isolate)
void(*)(Isolate *, void *) MicrotasksCompletedCallbackWithData
void(*)(void *data) MicrotaskCallback
MicrotasksPolicy
#define V8_EXPORT
Definition v8config.h:578
#define V8_NODISCARD
Definition v8config.h:513