Files
node/src/api/async_resource.cc
T
Daniel Bevenius 901343fa43 src: remove unused using declarations in src/api
PR-URL: https://github.com/nodejs/node/pull/28506
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-07-05 08:33:04 +02:00

74 lines
2.4 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#include "node.h"
#include "env-inl.h"
namespace node {
using v8::Function;
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)
: env_(Environment::GetCurrent(isolate)),
resource_(isolate, resource) {
CHECK_NOT_NULL(env_);
async_context_ = EmitAsyncInit(isolate, resource, name,
trigger_async_id);
}
AsyncResource::~AsyncResource() {
EmitAsyncDestroy(env_, async_context_);
resource_.Reset();
}
MaybeLocal<Value> AsyncResource::MakeCallback(Local<Function> callback,
int argc,
Local<Value>* argv) {
return node::MakeCallback(env_->isolate(), get_resource(),
callback, argc, argv,
async_context_);
}
MaybeLocal<Value> AsyncResource::MakeCallback(const char* method,
int argc,
Local<Value>* argv) {
return node::MakeCallback(env_->isolate(), get_resource(),
method, argc, argv,
async_context_);
}
MaybeLocal<Value> AsyncResource::MakeCallback(Local<String> symbol,
int argc,
Local<Value>* argv) {
return node::MakeCallback(env_->isolate(), get_resource(),
symbol, argc, argv,
async_context_);
}
Local<Object> AsyncResource::get_resource() {
return resource_.Get(env_->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;
}
// TODO(addaleax): We shouldn’t need to use env_->isolate() if we’re just going
// to end up using the Isolate* to figure out the Environment* again.
AsyncResource::CallbackScope::CallbackScope(AsyncResource* res)
: node::CallbackScope(res->env_->isolate(),
res->resource_.Get(res->env_->isolate()),
res->async_context_) {}
} // namespace node