mirror of
https://github.com/nodejs/node.git
synced 2026-12-04 02:19:15 -05:00
Generalize the finalizer's second pass callback to make it cancellable and simplify the code around the second pass callback. With this change, it is determined that Reference::Finalize or RefBase::Finalize are called once, either from the env's shutdown, or from the env's second pass callback. All existing node-api js tests should pass without a touch. The js_native_api cctest is no longer applicable with this change, just removing it. PR-URL: https://github.com/nodejs/node/pull/44141 Refs: https://github.com/nodejs/node/issues/44071 Reviewed-By: Michael Dawson <midawson@redhat.com>
44 lines
1.3 KiB
C++
44 lines
1.3 KiB
C++
#ifndef SRC_NODE_API_INTERNALS_H_
|
|
#define SRC_NODE_API_INTERNALS_H_
|
|
|
|
#include "v8.h"
|
|
#define NAPI_EXPERIMENTAL
|
|
#include "env-inl.h"
|
|
#include "js_native_api_v8.h"
|
|
#include "node_api.h"
|
|
#include "util-inl.h"
|
|
|
|
struct node_napi_env__ : public napi_env__ {
|
|
node_napi_env__(v8::Local<v8::Context> context,
|
|
const std::string& module_filename);
|
|
|
|
bool can_call_into_js() const override;
|
|
v8::Maybe<bool> mark_arraybuffer_as_untransferable(
|
|
v8::Local<v8::ArrayBuffer> ab) const override;
|
|
void CallFinalizer(napi_finalize cb, void* data, void* hint) override;
|
|
template <bool enforceUncaughtExceptionPolicy>
|
|
void CallFinalizer(napi_finalize cb, void* data, void* hint);
|
|
|
|
void EnqueueFinalizer(v8impl::RefTracker* finalizer) override;
|
|
void DrainFinalizerQueue();
|
|
|
|
void trigger_fatal_exception(v8::Local<v8::Value> local_err);
|
|
template <bool enforceUncaughtExceptionPolicy, typename T>
|
|
void CallbackIntoModule(T&& call);
|
|
|
|
void DeleteMe() override;
|
|
|
|
inline node::Environment* node_env() const {
|
|
return node::Environment::GetCurrent(context());
|
|
}
|
|
inline const char* GetFilename() const { return filename.c_str(); }
|
|
|
|
std::string filename;
|
|
bool destructing = false;
|
|
bool finalization_scheduled = false;
|
|
};
|
|
|
|
using node_napi_env = node_napi_env__*;
|
|
|
|
#endif // SRC_NODE_API_INTERNALS_H_
|