GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — worker: hide MessagePort init function behind symbol · nodejs/node@2e30a68

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/internal
    • worker.js
  • src
    • env.h
    • node_messaging.cc
    • node_worker.cc
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/worker.js‎

Copy file name to clipboardExpand all lines: lib/internal/worker.js
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ util.inherits(MessagePort, EventEmitter);
2424
const {
2525
Worker: WorkerImpl,
2626
getEnvMessagePort,
27-
threadId
27+
threadId,
28+
oninit: oninit_symbol
2829
} = internalBinding('worker');
2930

3031
const isMainThread = threadId === 0;
@@ -93,7 +94,7 @@ function oninit() {
9394
setupPortReferencing(this, this, 'message');
9495
}
9596

96-
Object.defineProperty(MessagePort.prototype, 'oninit', {
97+
Object.defineProperty(MessagePort.prototype, oninit_symbol, {
9798
enumerable: true,
9899
writable: false,
99100
value: oninit
Collapse file

‎src/env.h‎

Copy file name to clipboardExpand all lines: src/env.h
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ struct PackageConfig {
113113
#define PER_ISOLATE_SYMBOL_PROPERTIES(V) \
114114
V(handle_onclose_symbol, "handle_onclose") \
115115
V(owner_symbol, "owner") \
116+
V(oninit_symbol, "oninit") \
116117

117118
// Strings are per-isolate primitives but Environment proxies them
118119
// for the sake of convenience. Strings should be ASCII-only.
@@ -219,7 +220,6 @@ struct PackageConfig {
219220
V(onhandshakedone_string, "onhandshakedone") \
220221
V(onhandshakestart_string, "onhandshakestart") \
221222
V(onheaders_string, "onheaders") \
222-
V(oninit_string, "oninit") \
223223
V(onmessage_string, "onmessage") \
224224
V(onnewsession_string, "onnewsession") \
225225
V(onocspresponse_string, "onocspresponse") \
Collapse file

‎src/node_messaging.cc‎

Copy file name to clipboardExpand all lines: src/node_messaging.cc
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ MessagePort::MessagePort(Environment* env,
421421
async()->data = static_cast<void*>(this);
422422

423423
Local<Value> fn;
424-
if (!wrap->Get(context, env->oninit_string()).ToLocal(&fn))
424+
if (!wrap->Get(context, env->oninit_symbol()).ToLocal(&fn))
425425
return;
426426

427427
if (fn->IsFunction()) {
Collapse file

‎src/node_worker.cc‎

Copy file name to clipboardExpand all lines: src/node_worker.cc
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,10 @@ void InitWorker(Local<Object> target,
501501
thread_id_string,
502502
Number::New(env->isolate(),
503503
static_cast<double>(env->thread_id()))).FromJust();
504+
Local<String> oninit_string = FIXED_ONE_BYTE_STRING(env->isolate(), "oninit");
505+
target->Set(env->context(),
506+
oninit_string,
507+
env->oninit_symbol()).FromJust();
504508
}
505509

506510
} // anonymous namespace

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.