n-api: add API for asynchronous functions (simpler version) by gabrielschulhof · Pull Request #17887 · nodejs/node
added
c++
labels
gabrielschulhof
changed the title
n-api: add API for asynchronous functions
n-api: add API for asynchronous functions (simpler version)
mhdawson
added
the
semver-minor
label
gabrielschulhof pushed a commit that referenced this pull request
Bundle a `uv_async_t`, a `uv_idle_t`, a `uv_mutex_t`, a `uv_cond_t`, and a `v8::Persistent<v8::Function>` to make it possible to call into JS from another thread. The API accepts a void data pointer and a callback which will be invoked on the loop thread and which will receive the `napi_value` representing the JavaScript function to call so as to perform the call into JS. The callback is run inside a `node::CallbackScope`. A `std::queue<void*>` is used to store calls from the secondary threads, and an idle loop is started by the `uv_async_t` callback on the loop thread to drain the queue, calling into JS with each item. Items can be added to the queue blockingly or non-blockingly. The thread-safe function can be referenced or unreferenced, with the same semantics as libuv handles. Re: nodejs/help#1035 Re: #20964 Fixes: #13512 PR-URL: #17887 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
targos pushed a commit that referenced this pull request
Bundle a `uv_async_t`, a `uv_idle_t`, a `uv_mutex_t`, a `uv_cond_t`, and a `v8::Persistent<v8::Function>` to make it possible to call into JS from another thread. The API accepts a void data pointer and a callback which will be invoked on the loop thread and which will receive the `napi_value` representing the JavaScript function to call so as to perform the call into JS. The callback is run inside a `node::CallbackScope`. A `std::queue<void*>` is used to store calls from the secondary threads, and an idle loop is started by the `uv_async_t` callback on the loop thread to drain the queue, calling into JS with each item. Items can be added to the queue blockingly or non-blockingly. The thread-safe function can be referenced or unreferenced, with the same semantics as libuv handles. Re: nodejs/help#1035 Re: #20964 Fixes: #13512 PR-URL: #17887 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
cjihrig added a commit to cjihrig/node that referenced this pull request
private field 'async_context' is not used [-Wunused-private-field] PR-URL: nodejs#21597 Refs: nodejs#17887 Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
targos pushed a commit that referenced this pull request
targos added a commit that referenced this pull request
Notable changes:
* build:
* Node.js should now be about 60% faster to startup than the previous version,
thanks to the use V8's code cache feature for core modules. [#21405](#21405)
* dns:
* An experimental promisified version of the dns module is now available. Give
it a try with `require('dns').promises`. [#21264](#21264)
* fs:
* `fs.lchown` has been undeprecated now that libuv supports it. [#21498](#21498)
* lib:
* `Atomics.wake` is being renamed to `Atomics.notify` in the ECMAScript
specification ([reference](tc39/ecma262#1220)).
Since Node.js now has experimental support for worker threads, we are being
proactive and added a `notify` alias, while emitting a warning if
`wake` is used. [#21413](#21413) [#21518](#21518)
* n-api:
* Add API for asynchronous functions. [#17887](#17887)
* util:
* `util.inspect` is now able to return a result instead of throwing when the
maximum call stack size is exceeded during inspection. [#20725](#20725)
* vm:
* Add `script.createCachedData()`. This API replaces the `produceCachedData`
option of the `Script` constructor that is now deprecated. [#20300](#20300)
* worker:
* Support for relative paths has been added to the `Worker` constructor. Paths
are interpreted relative to the current working directory. [#21407](#21407)
PR-URL: #21629
targos added a commit that referenced this pull request
Notable changes:
* dns:
* An experimental promisified version of the dns module is now available. Give
it a try with `require('dns').promises`. [#21264](#21264)
* fs:
* `fs.lchown` has been undeprecated now that libuv supports it. [#21498](#21498)
* lib:
* `Atomics.wake` is being renamed to `Atomics.notify` in the ECMAScript
specification ([reference](tc39/ecma262#1220)).
Since Node.js now has experimental support for worker threads, we are being
proactive and added a `notify` alias, while emitting a warning if
`wake` is used. [#21413](#21413) [#21518](#21518)
* n-api:
* Add API for asynchronous functions. [#17887](#17887)
* util:
* `util.inspect` is now able to return a result instead of throwing when the
maximum call stack size is exceeded during inspection. [#20725](#20725)
* vm:
* Add `script.createCachedData()`. This API replaces the `produceCachedData`
option of the `Script` constructor that is now deprecated. [#20300](#20300)
* worker:
* Support for relative paths has been added to the `Worker` constructor. Paths
are interpreted relative to the current working directory. [#21407](#21407)
PR-URL: #21629
targos added a commit that referenced this pull request
Notable changes:
* dns:
* An experimental promisified version of the dns module is now available. Give
it a try with `require('dns').promises`. [#21264](#21264)
* fs:
* `fs.lchown` has been undeprecated now that libuv supports it. [#21498](#21498)
* lib:
* `Atomics.wake` is being renamed to `Atomics.notify` in the ECMAScript
specification ([reference](tc39/ecma262#1220)).
Since Node.js now has experimental support for worker threads, we are being
proactive and added a `notify` alias, while emitting a warning if
`wake` is used. [#21413](#21413) [#21518](#21518)
* n-api:
* Add API for asynchronous functions. [#17887](#17887)
* util:
* `util.inspect` is now able to return a result instead of throwing when the
maximum call stack size is exceeded during inspection. [#20725](#20725)
* vm:
* Add `script.createCachedData()`. This API replaces the `produceCachedData`
option of the `Script` constructor that is now deprecated. [#20300](#20300)
* worker:
* Support for relative paths has been added to the `Worker` constructor. Paths
are interpreted relative to the current working directory. [#21407](#21407)
PR-URL: #21629
gabrielschulhof pushed a commit to gabrielschulhof/node that referenced this pull request
Bundle a `uv_async_t`, a `uv_idle_t`, a `uv_mutex_t`, a `uv_cond_t`, and a `v8::Persistent<v8::Function>` to make it possible to call into JS from another thread. The API accepts a void data pointer and a callback which will be invoked on the loop thread and which will receive the `napi_value` representing the JavaScript function to call so as to perform the call into JS. The callback is run inside a `node::CallbackScope`. A `std::queue<void*>` is used to store calls from the secondary threads, and an idle loop is started by the `uv_async_t` callback on the loop thread to drain the queue, calling into JS with each item. Items can be added to the queue blockingly or non-blockingly. The thread-safe function can be referenced or unreferenced, with the same semantics as libuv handles. Re: nodejs/help#1035 Re: nodejs#20964 Fixes: nodejs#13512 PR-URL: nodejs#17887 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
gabrielschulhof pushed a commit to gabrielschulhof/node that referenced this pull request
private field 'async_context' is not used [-Wunused-private-field] PR-URL: nodejs#21597 Refs: nodejs#17887 Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
MylesBorins pushed a commit that referenced this pull request
Bundle a `uv_async_t`, a `uv_idle_t`, a `uv_mutex_t`, a `uv_cond_t`, and a `v8::Persistent<v8::Function>` to make it possible to call into JS from another thread. The API accepts a void data pointer and a callback which will be invoked on the loop thread and which will receive the `napi_value` representing the JavaScript function to call so as to perform the call into JS. The callback is run inside a `node::CallbackScope`. A `std::queue<void*>` is used to store calls from the secondary threads, and an idle loop is started by the `uv_async_t` callback on the loop thread to drain the queue, calling into JS with each item. Items can be added to the queue blockingly or non-blockingly. The thread-safe function can be referenced or unreferenced, with the same semantics as libuv handles. Re: nodejs/help#1035 Re: #20964 Fixes: #13512 Backport-PR-URL: #25002 PR-URL: #17887 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
MylesBorins pushed a commit that referenced this pull request
rvagg pushed a commit that referenced this pull request
Bundle a `uv_async_t`, a `uv_idle_t`, a `uv_mutex_t`, a `uv_cond_t`, and a `v8::Persistent<v8::Function>` to make it possible to call into JS from another thread. The API accepts a void data pointer and a callback which will be invoked on the loop thread and which will receive the `napi_value` representing the JavaScript function to call so as to perform the call into JS. The callback is run inside a `node::CallbackScope`. A `std::queue<void*>` is used to store calls from the secondary threads, and an idle loop is started by the `uv_async_t` callback on the loop thread to drain the queue, calling into JS with each item. Items can be added to the queue blockingly or non-blockingly. The thread-safe function can be referenced or unreferenced, with the same semantics as libuv handles. Re: nodejs/help#1035 Re: #20964 Fixes: #13512 Backport-PR-URL: #25002 PR-URL: #17887 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
rvagg pushed a commit that referenced this pull request
MylesBorins added a commit that referenced this pull request
MylesBorins added a commit that referenced this pull request
MylesBorins added a commit that referenced this pull request
MylesBorins added a commit that referenced this pull request
This was referenced