TinyWebServer icon indicating copy to clipboard operation
TinyWebServer copied to clipboard

log/block_queue.h中的定时pop

Open kgp123123 opened this issue 2 years ago • 1 comments

是什么原因使这里要进行两次检验啊(如果上一步timewait为true,那m_size应该就不会是0了,因为所有相关操作都加了锁)? if (m_size <= 0) { t.tv_sec = now.tv_sec + ms_timeout / 1000; t.tv_nsec = (ms_timeout % 1000) * 1000; if (!m_cond.timewait(m_mutex.get(), t)) { m_mutex.unlock(); return false; } } if (m_size <= 0) { m_mutex.unlock(); return false; }

kgp123123 avatar Feb 23 '22 13:02 kgp123123

我也感觉是多余的,有数据而且当前也加了锁,应该不可能再产生为0的情况了吧

Monkey-D-Luffy-star avatar Jul 13 '22 07:07 Monkey-D-Luffy-star