diff options
author | taylor.woll <tawoll@ntdev.microsoft.com> | 2017-03-28 02:06:58 -0700 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2017-04-11 01:09:46 +0200 |
commit | 9decfb15215978b73094ffb7a4bdf2a0da010258 (patch) | |
tree | c49d73c4cd519aba60e7a86b7ea5779ac73d675f /test/addons-napi/test_async/binding.gyp | |
parent | ca786c3734f6e23e34cd60f13e6bdaab033c5739 (diff) | |
download | android-node-v8-9decfb15215978b73094ffb7a4bdf2a0da010258.tar.gz android-node-v8-9decfb15215978b73094ffb7a4bdf2a0da010258.tar.bz2 android-node-v8-9decfb15215978b73094ffb7a4bdf2a0da010258.zip |
n-api: implement async helper methods
Based on the async methods we had in abi-stable-node before the napi
feature landed in node/master. Changed this set of APIs to handle
error cases and removed a lot of the extra methods we had for setting
all the pieces of napi_work opting instead to pass all of those as
arguments to napi_create_async_work as none of those parameters are
optional except for the complete callback, anyway.
Renamed the napi_work struct to napi_async_work and replace the
struct itself with a class which can better encapsulate the object
lifetime and uv_work_t that we're trying to wrap anyway.
Added a napi_async_callback type for the async helper callbacks
instead of taking raw function pointers and make this callback take a
napi_env parameter as well as the void* data it was already taking.
Call the complete handler for the async work item with a napi_status
code translated from the uvlib error code.
The execute callback is required for napi_create_async_work, though
complete callback is still optional.
Also added some async unit tests for addons-napi based on the
addons/async_hello_world test.
PR-URL: https://github.com/nodejs/node/pull/12250
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Hitesh Kanwathirtha <hiteshk@microsoft.com>
Diffstat (limited to 'test/addons-napi/test_async/binding.gyp')
-rw-r--r-- | test/addons-napi/test_async/binding.gyp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/test/addons-napi/test_async/binding.gyp b/test/addons-napi/test_async/binding.gyp new file mode 100644 index 0000000000..cf8beb70c6 --- /dev/null +++ b/test/addons-napi/test_async/binding.gyp @@ -0,0 +1,8 @@ +{ + "targets": [ + { + "target_name": "test_async", + "sources": [ "test_async.cc" ] + } + ] +} |