mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
22cbbcf9d9
Sometimes addons need to perform cleanup actions, for example closing libuv handles or waiting for requests to finish, that cannot be performed synchronously. Add C++ API and N-API functions that allow providing such asynchronous cleanup hooks. Fixes: https://github.com/nodejs/node/issues/34567 PR-URL: https://github.com/nodejs/node/pull/34572 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
9 lines
343 B
JavaScript
9 lines
343 B
JavaScript
'use strict';
|
|
const common = require('../../common');
|
|
const path = require('path');
|
|
const { Worker } = require('worker_threads');
|
|
const binding = path.resolve(__dirname, `./build/${common.buildType}/binding`);
|
|
|
|
const w = new Worker(`require(${JSON.stringify(binding)})`, { eval: true });
|
|
w.on('exit', common.mustCall(() => require(binding)));
|