src: make OnWorkComplete and OnExecute override-able#589
src: make OnWorkComplete and OnExecute override-able#589legendecas wants to merge 3 commits intonodejs:masterfrom
Conversation
0eb4bba to
e1e5e6f
Compare
|
Just mark the PR as working in progress. |
e1e5e6f to
016d91d
Compare
|
There might be issues on sharing the AsyncProgressWorker base class between AsyncProgressWorker and AsyncProgressQueueWorker if the ThreadSafeFunction queue size is different: a possible redundant wrapper around ThreadSafeFunction Call might be introduced to AsyncProgressWorker. So I'd like to remove the AsyncProgressWorker base class from the PR and leave the PR for the AsyncWorker's methods. |
|
This one is ready to be reviewed @nodejs/n-api please review/comment. |
|
|
||
| ### OnWorkComplete | ||
|
|
||
| This method is invoked after the work has completed on JavaScript thread. |
There was a problem hiding this comment.
Nit:
| This method is invoked after the work has completed on JavaScript thread. | |
| This method is invoked after the work has completed on the JavaScript thread. |
ba820aa to
3da380b
Compare
| // The OnAsyncWorkExecute method receives an napi_env argument. However, do NOT | ||
| // use it within this method, as it does not run on the main thread and must | ||
| // not run any method that would cause JavaScript to run. In practice, this | ||
| // means that almost any use of napi_env will be incorrect. |
There was a problem hiding this comment.
This blurb should be copied into the documentation above.
| #ifdef NAPI_CPP_EXCEPTIONS | ||
| try { | ||
| self->Execute(); | ||
| this->Execute(); |
There was a problem hiding this comment.
Do we need this-> here and in the lines below?
| inline void AsyncWorker::OnWorkComplete(Napi::Env /*env*/, napi_status status) { | ||
| if (status != napi_cancelled) { | ||
| HandleScope scope(self->_env); | ||
| HandleScope scope(this->_env); |
There was a problem hiding this comment.
Same here. I don't think we need this->.
Noticed some greater-than-nit things like the removal of this->
No breaking changes on existing code were expected. All existing tests shall pass without any touch. Changes on declaration: - Added `Napi::AsyncWorker::OnWorkComplete`. - Added `Napi::AsyncWorker::OnExecute`.
3da380b to
0de964c
Compare
|
@gabrielschulhof updated! PTAL :D |
gabrielschulhof
left a comment
There was a problem hiding this comment.
LGTM with a few nits.
| The default implementation of this method just calls the `Napi::AsyncWorker::Execute` | ||
| and handles exceptions if cpp exceptions were enabled. | ||
|
|
||
| The `OnExecute` method receives an `napi_env` argument. However, do NOT |
There was a problem hiding this comment.
| The `OnExecute` method receives an `napi_env` argument. However, do NOT | |
| The `OnExecute` method receives an `napi_env` argument. However, it must NOT be used |
| and handles exceptions if cpp exceptions were enabled. | ||
|
|
||
| The `OnExecute` method receives an `napi_env` argument. However, do NOT | ||
| use it within this method, as it does not run on the JavaScript thread and |
There was a problem hiding this comment.
| use it within this method, as it does not run on the JavaScript thread and | |
| within this method, as it does not run on the JavaScript thread and |
|
CI:
|
No breaking changes on existing code were expected. All existing tests shall pass without any touch. Changes on declaration: - Added `Napi::AsyncWorker::OnWorkComplete`. - Added `Napi::AsyncWorker::OnExecute`. PR-URL: #589 Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
|
Landed in 23ff7f0. |
No breaking changes on existing code were expected. All existing tests shall pass without any touch. Changes on declaration: - Added `Napi::AsyncWorker::OnWorkComplete`. - Added `Napi::AsyncWorker::OnExecute`. PR-URL: nodejs/node-addon-api#589 Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
No breaking changes on existing code were expected. All existing tests shall pass without any touch. Changes on declaration: - Added `Napi::AsyncWorker::OnWorkComplete`. - Added `Napi::AsyncWorker::OnExecute`. PR-URL: nodejs/node-addon-api#589 Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
No breaking changes on existing code were expected. All existing tests shall pass without any touch. Changes on declaration: - Added `Napi::AsyncWorker::OnWorkComplete`. - Added `Napi::AsyncWorker::OnExecute`. PR-URL: nodejs/node-addon-api#589 Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
No breaking changes on existing code were expected. All existing tests shall pass without any touch. Changes on declaration: - Added `Napi::AsyncWorker::OnWorkComplete`. - Added `Napi::AsyncWorker::OnExecute`. PR-URL: nodejs/node-addon-api#589 Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
No breaking changes on existing code were expected. All existing tests shall pass without any touch.
Changes on declaration:
Napi::AsyncWorker::OnWorkComplete.Napi::AsyncWorker::OnExecute.Fixes: #582