Commit 602da649 authored by Gabriel Schulhof's avatar Gabriel Schulhof
Browse files

src: add context-aware init macro and doc

Introduces macros `NODE_MODULE_INITIALIZER` which expands to the name
of the special symbol that process.dlopen() will look for to initialize
an addon, and `NODE_MODULE_INIT()` which creates the boilerplate for
a context-aware module which can be loaded multiple times via the
special symbol mechanism.

Additionally, provides an example of using the new macro to construct
an addon which stores per-addon-instance data in a heap-allocated
structure that gets passed to each binding, rather than in a collection
of global static variables.

Re: https://github.com/nodejs/node/issues/21291#issuecomment-396729727
PR-URL: https://github.com/nodejs/node/pull/21318


Reviewed-By: default avatarMatteo Collina <matteo.collina@gmail.com>
Reviewed-By: default avatarJames M Snell <jasnell@gmail.com>
Reviewed-By: default avatarUjjwal Sharma <usharma1998@gmail.com>
parent a15ea5d7
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment