Skip to content

Commit

Permalink
DataBuffer.h: add parentheses to clarify conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
jj1bdx committed Sep 3, 2022
1 parent d6e5712 commit 445e4b4
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions include/DataBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ template <class Element> class DataBuffer {
std::size_t queued_samples() {
{
std::lock_guard<std::mutex> lock(m_mutex);
return m_qlen;
return (m_qlen);
// unlock m_mutex here by getting out of scope
}
}
Expand All @@ -72,13 +72,13 @@ template <class Element> class DataBuffer {
std::vector<Element> ret;
{
std::unique_lock<std::mutex> lock(m_mutex);
m_cond.wait(lock, [&] { return !(m_queue.empty() && !m_end_marked); });
m_cond.wait(lock, [&] { return !(m_queue.empty() && (!m_end_marked)); });
if (!m_queue.empty()) {
m_qlen -= m_queue.front().size();
std::swap(ret, m_queue.front());
m_queue.pop();
}
return ret;
return (ret);
// unlock m_mutex here by getting out of scope
}
}
Expand All @@ -87,15 +87,15 @@ template <class Element> class DataBuffer {
bool pull_end_reached() {
{
std::lock_guard<std::mutex> lock(m_mutex);
return (m_qlen == 0 && m_end_marked);
return ((m_qlen == 0) && (m_end_marked));
// unlock m_mutex here by getting out of scope
}
}

/** Wait until the buffer contains minfill samples or an end marker. */
void wait_buffer_fill(std::size_t minfill) {
std::unique_lock<std::mutex> lock(m_mutex);
m_cond.wait(lock, [&] { return !(m_qlen < minfill && !m_end_marked); });
m_cond.wait(lock, [&] { return !((m_qlen < minfill) && (!m_end_marked)); });
}

private:
Expand Down

0 comments on commit 445e4b4

Please sign in to comment.