Skip to content

Commit

Permalink
fix: simplified condition variable use
Browse files Browse the repository at this point in the history
removed redundant unlock() and lambda function in
- Server::wait_running()
- Server::wait_stopped()

Signed-off-by: James Chapman <[email protected]>
  • Loading branch information
james-ctc committed Jul 29, 2024
1 parent 077b12d commit f6bbee5
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/staging/tls/tls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1198,14 +1198,16 @@ void Server::stop() {

void Server::wait_running() {
std::unique_lock lock(m_cv_mutex);
m_cv.wait(lock, [this] { return m_running; });
lock.unlock();
while (!m_running) {
m_cv.wait(lock);
}
}

void Server::wait_stopped() {
std::unique_lock lock(m_cv_mutex);
m_cv.wait(lock, [this] { return !m_running; });
lock.unlock();
while (m_running) {
m_cv.wait(lock);
}
}

// ----------------------------------------------------------------------------
Expand Down

0 comments on commit f6bbee5

Please sign in to comment.