diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2019-03-22 12:23:51 +0300 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2019-04-04 16:23:11 +0300 |
commit | eb2dccb17a7148e628a50a9c947a5f98513d8e63 (patch) | |
tree | 9b2eca4c14e3d9cce3359c19f29e833c3ad6223f /src/node.h | |
parent | e575ba608a1714320442027551e83aada31a94bb (diff) |
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: https://github.com/nodejs/node/pull/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>
Diffstat (limited to 'src/node.h')
-rw-r--r-- | src/node.h | 56 |
1 files changed, 14 insertions, 42 deletions
diff --git a/src/node.h b/src/node.h index 039b188f4f1..2923c60cf61 100644 --- a/src/node.h +++ b/src/node.h @@ -758,69 +758,41 @@ v8::MaybeLocal<v8::Value> MakeCallback(v8::Isolate* isolate, /* Helper class users can optionally inherit from. If * `AsyncResource::MakeCallback()` is used, then all four callbacks will be * called automatically. */ -class AsyncResource { +class NODE_EXTERN AsyncResource { public: AsyncResource(v8::Isolate* isolate, v8::Local<v8::Object> resource, const char* name, - async_id trigger_async_id = -1) - : isolate_(isolate), - resource_(isolate, resource) { - async_context_ = EmitAsyncInit(isolate, resource, name, - trigger_async_id); - } + async_id trigger_async_id = -1); - virtual ~AsyncResource() { - EmitAsyncDestroy(isolate_, async_context_); - resource_.Reset(); - } + virtual ~AsyncResource(); + + AsyncResource(const AsyncResource&) = delete; + void operator=(const AsyncResource&) = delete; v8::MaybeLocal<v8::Value> MakeCallback( v8::Local<v8::Function> callback, int argc, - v8::Local<v8::Value>* argv) { - return node::MakeCallback(isolate_, get_resource(), - callback, argc, argv, - async_context_); - } + v8::Local<v8::Value>* argv); v8::MaybeLocal<v8::Value> MakeCallback( const char* method, int argc, - v8::Local<v8::Value>* argv) { - return node::MakeCallback(isolate_, get_resource(), - method, argc, argv, - async_context_); - } + v8::Local<v8::Value>* argv); v8::MaybeLocal<v8::Value> MakeCallback( v8::Local<v8::String> symbol, int argc, - v8::Local<v8::Value>* argv) { - return node::MakeCallback(isolate_, get_resource(), - symbol, argc, argv, - async_context_); - } + v8::Local<v8::Value>* argv); - v8::Local<v8::Object> get_resource() { - return resource_.Get(isolate_); - } - - async_id get_async_id() const { - return async_context_.async_id; - } - - async_id get_trigger_async_id() const { - return async_context_.trigger_async_id; - } + v8::Local<v8::Object> get_resource(); + async_id get_async_id() const; + async_id get_trigger_async_id() const; protected: - class CallbackScope : public node::CallbackScope { + class NODE_EXTERN CallbackScope : public node::CallbackScope { public: - explicit CallbackScope(AsyncResource* res) - : node::CallbackScope(res->isolate_, - res->resource_.Get(res->isolate_), - res->async_context_) {} + explicit CallbackScope(AsyncResource* res); }; private: |