Skip to content

Commit

Permalink
rename to
Browse files Browse the repository at this point in the history
  • Loading branch information
dygabo committed Jun 4, 2024
1 parent 330bd1d commit f7cf9b6
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
10 changes: 5 additions & 5 deletions lib/internal/modules/esm/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ class HooksProxy {
*/
#lock;
/**
* The InternalWorker instance, which lets us communicate with the loader thread.
* The HooksWorker instance, which lets us communicate with the loader thread.
*/
#worker;

Expand All @@ -518,7 +518,7 @@ class HooksProxy {
#isWorkerOwner = false;

constructor() {
const { InternalWorker, hooksPort } = require('internal/worker');
const { HooksWorker, hooksPort } = require('internal/worker');
const lock = new SharedArrayBuffer(SHARED_MEMORY_BYTE_LENGTH);
this.#lock = new Int32Array(lock);

Expand All @@ -527,7 +527,7 @@ class HooksProxy {
// the existing instance. If another thread created it, the constructor will throw
// Fallback is to use the existing hooksPort created by the thread that originally
// spawned the customization hooks thread.
this.#worker = new InternalWorker(loaderWorkerId, {
this.#worker = new HooksWorker(loaderWorkerId, {
stderr: false,
stdin: false,
stdout: false,
Expand All @@ -551,10 +551,10 @@ class HooksProxy {

waitForWorker() {
// There is one Hooks instance for each worker thread. But only one of
// these Hooks instances has an InternalWorker. That was the Hooks instance
// these Hooks instances has a HooksWorker. That was the Hooks instance
// created for the first thread that registers a hook set.
// It means for all Hooks instances that are not on that thread => they are
// done because they delegate to the single InternalWorker.
// done because they delegate to the single HooksWorker.
if (!this.#isWorkerOwner) {
return;
}
Expand Down
8 changes: 4 additions & 4 deletions lib/internal/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -482,10 +482,10 @@ class Worker extends EventEmitter {
}

/**
* A worker which has an internal module for entry point (e.g. internal/module/esm/worker).
* Internal workers bypass the permission model.
* A worker which is used to by the customization hooks thread (internal/module/esm/worker).
* This bypasses the permission model.
*/
class InternalWorker extends Worker {
class HooksWorker extends Worker {
constructor(filename, options) {
super(filename, options, kIsInternal);
}
Expand Down Expand Up @@ -570,6 +570,6 @@ module.exports = {
getEnvironmentData,
assignEnvironmentData,
threadId,
InternalWorker,
HooksWorker,
Worker,
};
8 changes: 4 additions & 4 deletions src/node_worker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace node {
namespace worker {

constexpr double kMB = 1024 * 1024;
std::atomic_bool Worker::internalExists{false};
std::atomic_bool Worker::hooksWorkerExists{false};
Mutex Worker::instantiationMutex;

Worker::Worker(Environment* env,
Expand Down Expand Up @@ -498,14 +498,14 @@ void Worker::New(const FunctionCallbackInfo<Value>& args) {
CHECK(args.IsConstructCall());
auto creatingHooksThread = is_internal->IsTrue();

if (creatingHooksThread && internalExists) {
if (creatingHooksThread && hooksWorkerExists) {
isolate->ThrowException(ERR_HOOKS_THREAD_EXISTS(
isolate, "Customization hooks thread already exists"));
return;
}

if (creatingHooksThread) {
internalExists = true;
hooksWorkerExists = true;
}

if (env->isolate_data()->platform() == nullptr) {
Expand Down Expand Up @@ -918,7 +918,7 @@ void Worker::LoopStartTime(const FunctionCallbackInfo<Value>& args) {
}

void Worker::HasHooksThread(const FunctionCallbackInfo<Value>& args) {
args.GetReturnValue().Set(Worker::internalExists);
args.GetReturnValue().Set(Worker::hooksWorkerExists);
}

namespace {
Expand Down
2 changes: 1 addition & 1 deletion src/node_worker.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class Worker : public AsyncWrap {
uintptr_t stack_base_ = 0;
// Optional name used for debugging in inspector and trace events.
std::string name_;
static std::atomic_bool internalExists;
static std::atomic_bool hooksWorkerExists;
// this mutex is to synchronize ::New calls
static Mutex instantiationMutex;

Expand Down

0 comments on commit f7cf9b6

Please sign in to comment.