Conversation
|
@romandev thanks for putting this together. Can you add the doc for this class? I have a few questions but I think the doc would likely answer them and we'll need it anyway. |
|
@romandev are you going to have a chance to get back to this? |
|
@mhdawson, I'll update this patch in this week. |
|
@mhdawson I've pushed a new patch. Please take a look. |
| @@ -0,0 +1,107 @@ | |||
| # AsyncContext | |||
|
|
|||
| The `AsyncWorker` class may not be appropriate for every scenario, because with | |||
There was a problem hiding this comment.
Maybe could be good link the AsyncWorker doc
romandev
left a comment
There was a problem hiding this comment.
Thank you for review. I addressed your comments.
| @@ -0,0 +1,107 @@ | |||
| # AsyncContext | |||
|
|
|||
| The `AsyncWorker` class may not be appropriate for every scenario, because with | |||
8b13b94 to
4dc066e
Compare
| # AsyncContext | ||
|
|
||
| The [AsyncWorker](async_worker.md) class may not be appropriate for every scenario, because with | ||
| those the async execution still happens on the main event loop. When using any |
There was a problem hiding this comment.
I don't think this is quite right as the async execution happens in a thread from the existing thread pool. I'll have a closer look and add some I think describes the difference.
There was a problem hiding this comment.
I matched up with https://nodejs.org/api/n-api.html#n_api_custom_asynchronous_operations.
4dc066e to
ef365f6
Compare
NickNaso
left a comment
There was a problem hiding this comment.
Hi @romandev the code is good to me. Just some suggestions about the documentation. Recently we decided to use the complete namespace to refer at node-addon-api class. So please do another pass on documentation and add Napi namespace where necessary.
| @@ -0,0 +1,148 @@ | |||
| # AsyncContext | |||
|
|
|||
| The [AsyncWorker](async_worker.md) class may not be appropriate for every | |||
|
|
||
| The [AsyncWorker](async_worker.md) class may not be appropriate for every | ||
| scenario. When using any other async mechanism, introducing a new class | ||
| `AsyncContext`is necessary to ensure an async operation is properly tracked by |
There was a problem hiding this comment.
AsyncContext should be Napi::AsyncContext
| The [AsyncWorker](async_worker.md) class may not be appropriate for every | ||
| scenario. When using any other async mechanism, introducing a new class | ||
| `AsyncContext`is necessary to ensure an async operation is properly tracked by | ||
| the runtime. The `AsyncContext` class provides `MakeCallback()` method to |
There was a problem hiding this comment.
AsyncContext should be Napi::AsyncContext
| returning from an async operation (when there is no other script on the stack). | ||
|
|
||
| ```cpp | ||
| Value MakeCallback() const |
| Value MakeCallback() const | ||
| ``` | ||
|
|
||
| Returns a `Value` representing the JavaScript object returned. |
| Creates a new `AsyncContext`. | ||
|
|
||
| ```cpp | ||
| explicit AsyncContext(const char* resource_name, const Function& callback); |
| - `[in] callback`: The function which will be called when an asynchronous | ||
| operations ends. | ||
|
|
||
| Returns an AsyncContext instance which can later make the given callback by |
There was a problem hiding this comment.
an AsyncContext should be a Napi::AsyncContext
|
|
||
| ### Constructor | ||
|
|
||
| Creates a new `AsyncContext`. |
There was a problem hiding this comment.
AsyncContext should be Napi::AsyncContext
| Creates a new `AsyncContext`. | ||
|
|
||
| ```cpp | ||
| explicit AsyncContext(const char* resource_name, const Object& resource, const Function& callback); |
| - `[in] callback`: The function which will be called when an asynchronous | ||
| operations ends. | ||
|
|
||
| Returns an AsyncContext instance which can later make the given callback by |
There was a problem hiding this comment.
Returns an AsyncContext should be Returns a Napi::AsyncContext
|
@mhdawson Could you review this PR? |
|
@romandev sorry its taken so long to comment. A couple of high level comments/questions
|
|
@romandev if you can get to it this weekend I think it's worth waiting until next week for the release. |
ef365f6 to
aeab2b4
Compare
NickNaso
left a comment
There was a problem hiding this comment.
Some little fix to do for the rest it's ok to me.
| arguments of the function. | ||
| - `[in] context`: Context for the async operation that is invoking the callback. | ||
| This should normally be a value previously obtained from [Napi::AsyncContext](async_context.md). | ||
| However `nullptr` is also allowed, which indicates the currenc async context |
| arguments of the function. | ||
| - `[in] context`: Context for the async operation that is invoking the callback. | ||
| This should normally be a value previously obtained from [Napi::AsyncContext](async_context.md). | ||
| However `nullptr` is also allowed, which indicates the currenc async context |
| the arguments of the referenced function. | ||
| - `[in] context`: Context for the async operation that is invoking the callback. | ||
| This should normally be a value previously obtained from [Napi::AsyncContext](async_context.md). | ||
| However `nullptr` is also allowed, which indicates the currenc async context |
| arguments of the referenced function. | ||
| - `[in] context`: Context for the async operation that is invoking the callback. | ||
| This should normally be a value previously obtained from [Napi::AsyncContext](async_context.md). | ||
| However `nullptr` is also allowed, which indicates the currenc async context |
| arguments of the referenced function. | ||
| - `[in] context`: Context for the async operation that is invoking the callback. | ||
| This should normally be a value previously obtained from [Napi::AsyncContext](async_context.md). | ||
| However `nullptr` is also allowed, which indicates the currenc async context |
This class provides a wrapper for the following custom asynchronous operation APIs. - napi_async_init() - napi_async_destroy()
aeab2b4 to
0e6219b
Compare
|
FYI, I fixed typo as well :) |
|
@mhdawson Could you take a look at this PR? |
|
CI run to make sure its ok on 6.x https://ci.nodejs.org/view/x%20-%20Abi%20stable%20module%20API/job/node-test-node-addon-api/784/ |
This class provides a wrapper for the following custom asynchronous operation APIs. - napi_async_init() - napi_async_destroy() PR-URL: #252 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Nicola Del Gobbo <nicoladelgobbo@NickNaso.local>
|
Landed as dfcb939 |
This class provides a wrapper for the following custom asynchronous operation APIs. - napi_async_init() - napi_async_destroy() PR-URL: nodejs#252 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Nicola Del Gobbo <nicoladelgobbo@NickNaso.local>
This class provides a wrapper for the following custom asynchronous operation APIs. - napi_async_init() - napi_async_destroy() PR-URL: nodejs/node-addon-api#252 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Nicola Del Gobbo <nicoladelgobbo@NickNaso.local>
This class provides a wrapper for the following custom asynchronous operation APIs. - napi_async_init() - napi_async_destroy() PR-URL: nodejs/node-addon-api#252 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Nicola Del Gobbo <nicoladelgobbo@NickNaso.local>
This class provides a wrapper for the following custom asynchronous operation APIs. - napi_async_init() - napi_async_destroy() PR-URL: nodejs/node-addon-api#252 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Nicola Del Gobbo <nicoladelgobbo@NickNaso.local>
This class provides a wrapper for the following custom asynchronous operation APIs. - napi_async_init() - napi_async_destroy() PR-URL: nodejs/node-addon-api#252 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Nicola Del Gobbo <nicoladelgobbo@NickNaso.local>
This class provides a wrapper for the following custom asynchronous
operation APIs.
This PR is initiated from #140 (comment).