v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
async-hooks-wrapper.h
Go to the documentation of this file.
1// Copyright 2018 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 V8_D8_ASYNC_HOOKS_WRAPPER_H_
6#define V8_D8_ASYNC_HOOKS_WRAPPER_H_
7
8#include <stack>
9#include <vector>
10
13#include "include/v8-promise.h"
14
15namespace v8 {
16
17class Function;
18class Isolate;
19class ObjectTemplate;
20class Value;
21
22using async_id_t = double;
23
28
59
61 public:
62 explicit AsyncHooks(Isolate* isolate);
64
67
69
71
72 private:
73 std::vector<std::shared_ptr<AsyncHooksWrap>> async_wraps_;
78
79 static void ShellPromiseHook(PromiseHookType type, Local<Promise> promise,
80 Local<Value> parent);
81 static void PromiseHookDispatch(PromiseHookType type, Local<Promise> promise,
82 Local<Value> parent,
83 const AsyncHooksWrap& wrap,
84 AsyncHooks* hooks);
85
86 std::stack<AsyncContext> asyncContexts;
88 // We might end up in an invalid state after skipping steps due to
89 // terminations.
91};
92
93} // namespace v8
94
95#endif // V8_D8_ASYNC_HOOKS_WRAPPER_H_
void set_before_function(v8::Local< v8::Function > value)
void set_after_function(v8::Local< v8::Function > value)
Persistent< v8::Function > after_function_
void set_promiseResolve_function(v8::Local< v8::Function > value)
static constexpr internal::ExternalPointerTag kManagedTag
v8::Local< v8::Function > after_function() const
v8::Local< v8::Function > before_function() const
v8::Local< v8::Function > promiseResolve_function() const
void set_init_function(v8::Local< v8::Function > value)
AsyncHooksWrap(Isolate *isolate)
v8::Local< v8::Function > init_function() const
Persistent< v8::Function > init_function_
Persistent< v8::Function > promiseResolve_function_
Persistent< v8::Function > before_function_
std::stack< AsyncContext > asyncContexts
static void PromiseHookDispatch(PromiseHookType type, Local< Promise > promise, Local< Value > parent, const AsyncHooksWrap &wrap, AsyncHooks *hooks)
Persistent< ObjectTemplate > async_hooks_templ
v8::Isolate * v8_isolate_
Persistent< FunctionTemplate > async_hook_ctor
async_id_t current_async_id
Persistent< Private > trigger_id_symbol
std::vector< std::shared_ptr< AsyncHooksWrap > > async_wraps_
async_id_t GetTriggerAsyncId() const
AsyncHooks(Isolate *isolate)
async_id_t GetExecutionAsyncId() const
Persistent< Private > async_id_symbol
static void ShellPromiseHook(PromiseHookType type, Local< Promise > promise, Local< Value > parent)
Local< Object > CreateHook(const v8::FunctionCallbackInfo< v8::Value > &info)
double async_id_t
PromiseHookType
Definition v8-promise.h:141
async_id_t execution_async_id