-
Notifications
You must be signed in to change notification settings - Fork 4k
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
代码错误 #296
Comments
我也赞同时间处理有问题, 但是我认为 bool pop(T &item, int ms_timeout) 是没有问题的 , 因为这份代码进行了双检测, 在 线程被唤醒后, 会再一次确认队列中是否有数据进行处理 |
此外, 如果说被唤醒后队列事实上已经不存在数据需要处理了 就直接返回false |
你说的对,我没有考虑到 |
我这样改了之后,会阻塞等待,那么就没有写超时等待的必要了 |
1.block_queue.h中pop函数调用的timewait不在while循环中,可能会出现线程虚假唤醒的现象,应该在while(m_size<=0)循环中调用timewait函数
2.pop函数中的时间处理也有问题
修改后的代码如下
The text was updated successfully, but these errors were encountered: