Skip to content

Commit

Permalink
src: check for tsfn in conditional_variable wait
Browse files Browse the repository at this point in the history
Fixes: #1150

PR-URL: nodejs/node-addon-api#1168
Reviewed-By: Michael Dawson <midawson@redhat.com
  • Loading branch information
Marlyfleitas committed Apr 20, 2022
1 parent 8e37550 commit 310212d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion test/threadsafe_function/threadsafe_function_sum.cc
Expand Up @@ -81,7 +81,7 @@ class DelayedTSFNTask {
// Entry point for std::thread
void entryDelayedTSFN(int threadId) {
std::unique_lock<std::mutex> lk(mtx);
cv.wait(lk);
cv.wait(lk, [this] { return this->tsfn != nullptr; });
tsfn.BlockingCall([=](Napi::Env env, Function callback) {
callback.Call({Number::New(env, static_cast<double>(threadId))});
});
Expand Down
Expand Up @@ -99,7 +99,7 @@ class DelayedTSFNTask {
// Entry point for std::thread
void entryDelayedTSFN(int threadId) {
std::unique_lock<std::mutex> lk(mtx);
cv.wait(lk);
cv.wait(lk, [this] { return this->tsfn != nullptr; });
tsfn.BlockingCall(new double(threadId));
tsfn.Release();
};
Expand Down

0 comments on commit 310212d

Please sign in to comment.