-
-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Close without destroy #239
The head ref may contain hidden characters: "close-w\u0131thout-destroy"
Changes from all commits
c93e8e4
d75cf3e
bd81b33
82c68d7
bf3c553
5bd410b
0abeeb2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/** @type {import('jest').Config} */ | ||
const config = { | ||
verbose: true, | ||
testPathIgnorePatterns: ['<rootDir>/node_modules/', 'multiple-run.test'], | ||
}; | ||
|
||
module.exports = config; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,9 +26,9 @@ ThreadSafeCallback::~ThreadSafeCallback() | |
tsfn.Abort(); | ||
} | ||
|
||
void ThreadSafeCallback::call(arg_func_t argFunc) | ||
void ThreadSafeCallback::call(arg_func_t argFunc, cleanup_func_t cleanupFunc) | ||
{ | ||
CallbackData *data = new CallbackData{std::move(argFunc)}; | ||
CallbackData *data = new CallbackData{std::move(argFunc), std::move(cleanupFunc)}; | ||
if (tsfn.BlockingCall(data) != napi_ok) | ||
{ | ||
delete data; | ||
|
@@ -47,6 +47,7 @@ void ThreadSafeCallback::callbackFunc(Napi::Env env, | |
|
||
arg_vector_t args; | ||
arg_func_t argFunc(std::move(data->argFunc)); | ||
cleanup_func_t cleanup(std::move(data->cleanupFunc)); | ||
delete data; | ||
|
||
try | ||
|
@@ -59,5 +60,8 @@ void ThreadSafeCallback::callbackFunc(Napi::Env env, | |
} | ||
|
||
if (env && callback) | ||
{ | ||
callback.Call(context->Value(), args); | ||
cleanup(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think |
||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I'm not mistaken,
doCleanup()
won't be called if the user did not set a closed callback.