Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

log/block_queue.h中的定时pop #102

Open
ghost opened this issue Feb 23, 2022 · 2 comments
Open

log/block_queue.h中的定时pop #102

ghost opened this issue Feb 23, 2022 · 2 comments

Comments

@ghost
Copy link

ghost commented Feb 23, 2022

是什么原因使这里要进行两次检验啊(如果上一步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;
}

@QAQEthan
Copy link

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

@vicky-beep
Copy link

我也认为有些多余

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants