forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
src: move AsyncResource impl out of public header
Implementing the methods out-of-line (i.e., not inline) means we can fix bugs and have already compiled add-ons pick up the fixes automatically, something that doesn't work when the methods are inline because then they get compiled into the add-on instead of the node binary. PR-URL: nodejs#26348 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
- Loading branch information
1 parent
e575ba6
commit eb2dccb
Showing
3 changed files
with
85 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#include "node.h" | ||
|
||
namespace node { | ||
|
||
using v8::Function; | ||
using v8::HandleScope; | ||
using v8::Isolate; | ||
using v8::Local; | ||
using v8::MaybeLocal; | ||
using v8::Object; | ||
using v8::String; | ||
using v8::Value; | ||
|
||
AsyncResource::AsyncResource(Isolate* isolate, | ||
Local<Object> resource, | ||
const char* name, | ||
async_id trigger_async_id) | ||
: isolate_(isolate), | ||
resource_(isolate, resource) { | ||
async_context_ = EmitAsyncInit(isolate, resource, name, | ||
trigger_async_id); | ||
} | ||
|
||
AsyncResource::~AsyncResource() { | ||
EmitAsyncDestroy(isolate_, async_context_); | ||
resource_.Reset(); | ||
} | ||
|
||
MaybeLocal<Value> AsyncResource::MakeCallback(Local<Function> callback, | ||
int argc, | ||
Local<Value>* argv) { | ||
return node::MakeCallback(isolate_, get_resource(), | ||
callback, argc, argv, | ||
async_context_); | ||
} | ||
|
||
MaybeLocal<Value> AsyncResource::MakeCallback(const char* method, | ||
int argc, | ||
Local<Value>* argv) { | ||
return node::MakeCallback(isolate_, get_resource(), | ||
method, argc, argv, | ||
async_context_); | ||
} | ||
|
||
MaybeLocal<Value> AsyncResource::MakeCallback(Local<String> symbol, | ||
int argc, | ||
Local<Value>* argv) { | ||
return node::MakeCallback(isolate_, get_resource(), | ||
symbol, argc, argv, | ||
async_context_); | ||
} | ||
|
||
Local<Object> AsyncResource::get_resource() { | ||
return resource_.Get(isolate_); | ||
} | ||
|
||
async_id AsyncResource::get_async_id() const { | ||
return async_context_.async_id; | ||
} | ||
|
||
async_id AsyncResource::get_trigger_async_id() const { | ||
return async_context_.trigger_async_id; | ||
} | ||
|
||
AsyncResource::CallbackScope::CallbackScope(AsyncResource* res) | ||
: node::CallbackScope(res->isolate_, | ||
res->resource_.Get(res->isolate_), | ||
res->async_context_) {} | ||
|
||
} // namespace node |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters