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: #1168
Reviewed-By: Michael Dawson <[email protected]
  • Loading branch information
KevinEady authored and mhdawson committed Apr 20, 2022
1 parent 40ed7ce commit 24455f8
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 24455f8

Please sign in to comment.