We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 73ce6ce commit 86e15b2Copy full SHA for 86e15b2
slides/thread/mtqueue.hpp
@@ -96,7 +96,7 @@ struct mt_queue {
96
// 尝试取数据,如果没有,等待直到时间点,超时返回 nullopt
97
std::optional<T> try_pop_until(std::chrono::steady_clock::time_point timeout) {
98
std::unique_lock lock(m_mutex);
99
- if (!m_cv_empty.wait_for(lock, timeout, [&] { return !m_queue.empty(); }))
+ if (!m_cv_empty.wait_until(lock, timeout, [&] { return !m_queue.empty(); }))
100
return std::nullopt;
101
T value = std::move(m_queue.back());
102
m_queue.pop_back();
0 commit comments