Skip to content

Commit

Permalink
Update mtqueue.hpp
Browse files Browse the repository at this point in the history
  • Loading branch information
archibate authored Oct 18, 2024
1 parent 73ce6ce commit 86e15b2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion slides/thread/mtqueue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ struct mt_queue {
// 尝试取数据,如果没有,等待直到时间点,超时返回 nullopt
std::optional<T> try_pop_until(std::chrono::steady_clock::time_point timeout) {
std::unique_lock lock(m_mutex);
if (!m_cv_empty.wait_for(lock, timeout, [&] { return !m_queue.empty(); }))
if (!m_cv_empty.wait_until(lock, timeout, [&] { return !m_queue.empty(); }))
return std::nullopt;
T value = std::move(m_queue.back());
m_queue.pop_back();
Expand Down

0 comments on commit 86e15b2

Please sign in to comment.