@@ -17,28 +17,23 @@ AsyncResource::AsyncResource(Isolate* isolate, |
17 | 17 | const char* name, |
18 | 18 | async_id trigger_async_id) |
19 | 19 | : env_(Environment::GetCurrent(isolate)), |
20 | | - resource_(isolate, resource) { |
| 20 | + resource_(isolate, resource), |
| 21 | + context_frame_(isolate, async_context_frame::current(isolate)) { |
21 | 22 | CHECK_NOT_NULL(env_); |
22 | | - env_->SetAsyncResourceContextFrame( |
23 | | - reinterpret_cast<std::uintptr_t>(this), |
24 | | - {isolate, async_context_frame::current(isolate)}); |
25 | 23 | async_context_ = EmitAsyncInit(isolate, resource, name, trigger_async_id); |
26 | 24 | } |
27 | 25 |
|
28 | 26 | AsyncResource::~AsyncResource() { |
29 | 27 | CHECK_NOT_NULL(env_); |
30 | 28 | EmitAsyncDestroy(env_, async_context_); |
31 | | - env_->RemoveAsyncResourceContextFrame(reinterpret_cast<std::uintptr_t>(this)); |
32 | 29 | } |
33 | 30 |
|
34 | 31 | MaybeLocal<Value> AsyncResource::MakeCallback(Local<Function> callback, |
35 | 32 | int argc, |
36 | 33 | Local<Value>* argv) { |
37 | 34 | auto isolate = env_->isolate(); |
38 | | - auto context_frame = |
39 | | - env_->GetAsyncResourceContextFrame(reinterpret_cast<std::uintptr_t>(this)) |
40 | | - .Get(isolate); |
41 | | - async_context_frame::Scope async_context_frame_scope(isolate, context_frame); |
| 35 | + async_context_frame::Scope async_context_frame_scope( |
| 36 | + isolate, context_frame_.Get(isolate)); |
42 | 37 |
|
43 | 38 | return node::MakeCallback( |
44 | 39 | isolate, get_resource(), callback, argc, argv, async_context_); |
@@ -48,10 +43,8 @@ MaybeLocal<Value> AsyncResource::MakeCallback(const char* method, |
48 | 43 | int argc, |
49 | 44 | Local<Value>* argv) { |
50 | 45 | auto isolate = env_->isolate(); |
51 | | - auto context_frame = |
52 | | - env_->GetAsyncResourceContextFrame(reinterpret_cast<std::uintptr_t>(this)) |
53 | | - .Get(isolate); |
54 | | - async_context_frame::Scope async_context_frame_scope(isolate, context_frame); |
| 46 | + async_context_frame::Scope async_context_frame_scope( |
| 47 | + isolate, context_frame_.Get(isolate)); |
55 | 48 |
|
56 | 49 | return node::MakeCallback( |
57 | 50 | isolate, get_resource(), method, argc, argv, async_context_); |
@@ -61,10 +54,8 @@ MaybeLocal<Value> AsyncResource::MakeCallback(Local<String> symbol, |
61 | 54 | int argc, |
62 | 55 | Local<Value>* argv) { |
63 | 56 | auto isolate = env_->isolate(); |
64 | | - auto context_frame = |
65 | | - env_->GetAsyncResourceContextFrame(reinterpret_cast<std::uintptr_t>(this)) |
66 | | - .Get(isolate); |
67 | | - async_context_frame::Scope async_context_frame_scope(isolate, context_frame); |
| 57 | + async_context_frame::Scope async_context_frame_scope( |
| 58 | + isolate, context_frame_.Get(isolate)); |
68 | 59 |
|
69 | 60 | return node::MakeCallback( |
70 | 61 | isolate, get_resource(), symbol, argc, argv, async_context_); |
|