Skip to content

Commit

Permalink
Make sure the mutex is unlocked before promise.set_value
Browse files Browse the repository at this point in the history
  • Loading branch information
krishung5 committed May 15, 2023
1 parent 8da1d50 commit 2eb5c32
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/infer_payload.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ InferPayload::SetValue(std::unique_ptr<InferResponse> infer_response)
// Only set value to the promise with the first response. Call the callback
// function to send decoupled response to the stub.
{
std::lock_guard<std::mutex> lock(mutex_);
std::unique_lock<std::mutex> lock(mutex_);
if (!is_promise_set_) {
is_promise_set_ = true;
lock.unlock();
promise_->set_value(std::move(infer_response));
return;
}
Expand Down

0 comments on commit 2eb5c32

Please sign in to comment.